From 086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 10 Feb 2010 00:34:05 +0000 Subject: re-arranged into libdir and setup with the template Makefile+debian stuff. renabled vv+ and vv- as vvplus and vvminus svn path=/trunk/externals/smlib/; revision=13158 --- Makefile | 235 ++++++++++++++++++++++++++++++++++++++++++ SMLib-help.pd | 99 ++++++++++++++++++ SMLib.c | 234 +++++++++++++++++++++++++++++++++++++++++ SMLib.dsp | 275 +++++++++++++++++++++++++++++++++++++++++++++++++ SMLib.dsw | 29 ++++++ SMLib.opt | Bin 0 -> 48640 bytes SMLib.plg | 153 +++++++++++++++++++++++++++ bp-help.pd | 35 +++++++ bp.c | 123 ++++++++++++++++++++++ debian/changelog | 5 + debian/compat | 1 + debian/control | 16 +++ debian/copyright | 13 +++ debian/rules | 16 +++ decimator.c | 66 ++++++++++++ defines.h | 17 +++ deltas-help.pd | 34 ++++++ deltas.c | 181 ++++++++++++++++++++++++++++++++ help/SMLib-help.pd | 103 ------------------ help/bp-help.pd | 35 ------- help/deltas-help.pd | 34 ------ help/hip-help.pd | 32 ------ help/hist-help.pd | 44 -------- help/itov-help.pd | 44 -------- help/lavg-help.pd | 22 ---- help/lhist-help.pd | 40 ------- help/lhisti-help.pd | 41 -------- help/linspace-help.pd | 20 ---- help/lmax-help.pd | 22 ---- help/lmin-help.pd | 22 ---- help/lrange-help.pd | 22 ---- help/prevl-help.pd | 34 ------ help/threshold-help.pd | 50 --------- help/vabs-help.pd | 6 -- help/vclip-help.pd | 17 --- help/vcog-help.pd | 21 ---- help/vdbtorms-help.pd | 9 -- help/vdelta-help.pd | 29 ------ help/vfmod-help.pd | 17 --- help/vftom-help.pd | 9 -- help/vlavg-help.pd | 29 ------ help/vlmax-help.pd | 29 ------ help/vlmin-help.pd | 29 ------ help/vmax-help.pd | 21 ---- help/vmin-help.pd | 21 ---- help/vmtof-help.pd | 9 -- help/vpow-help.pd | 15 --- help/vrms-help.pd | 15 --- help/vrmstodb-help.pd | 9 -- help/vstd-help.pd | 15 --- help/vsum-help.pd | 13 --- help/vvconv-help.pd | 35 ------- help/vvminus-help.pd | 23 ----- help/vvplus-help.pd | 25 ----- hip-help.pd | 32 ++++++ hip.c | 77 ++++++++++++++ hist-help.pd | 44 ++++++++ hist.c | 155 ++++++++++++++++++++++++++++ itov-help.pd | 44 ++++++++ itov.c | 86 ++++++++++++++++ lavg-help.pd | 22 ++++ lavg.c | 55 ++++++++++ lhist-help.pd | 40 +++++++ lhist.c | 174 +++++++++++++++++++++++++++++++ lhisti-help.pd | 41 ++++++++ lhisti.c | 174 +++++++++++++++++++++++++++++++ linspace-help.pd | 20 ++++ linspace.c | 74 +++++++++++++ lmax-help.pd | 22 ++++ lmax.c | 57 ++++++++++ lmin-help.pd | 22 ++++ lmin.c | 57 ++++++++++ lrange-help.pd | 22 ++++ lrange.c | 60 +++++++++++ lstd-help.pd | 9 ++ lstd.c | 60 +++++++++++ prevl-help.pd | 34 ++++++ prevl.c | 161 +++++++++++++++++++++++++++++ smlib-meta.pd | 16 +++ source/SMLib.c | 234 ----------------------------------------- source/SMLib.dsp | 275 ------------------------------------------------- source/SMLib.dsw | 29 ------ source/SMLib.opt | Bin 48640 -> 0 bytes source/SMLib.plg | 153 --------------------------- source/bp.c | 123 ---------------------- source/decimator.c | 66 ------------ source/defines.h | 18 ---- source/deltas.c | 181 -------------------------------- source/hip.c | 77 -------------- source/hist.c | 155 ---------------------------- source/itov.c | 86 ---------------- source/lavg.c | 55 ---------- source/lhist.c | 174 ------------------------------- source/lhisti.c | 174 ------------------------------- source/linspace.c | 74 ------------- source/lmax.c | 57 ---------- source/lmin.c | 57 ---------- source/lrange.c | 60 ----------- source/lstd.c | 60 ----------- source/prevl.c | 161 ----------------------------- source/threshold.c | 112 -------------------- source/vabs.c | 48 --------- source/vclip.c | 58 ----------- source/vcog.c | 43 -------- source/vdbtorms.c | 56 ---------- source/vdelta.c | 75 -------------- source/vfmod.c | 57 ---------- source/vftom.c | 49 --------- source/vlavg.c | 86 ---------------- source/vlmax.c | 86 ---------------- source/vlmin.c | 86 ---------------- source/vlrange.c | 99 ------------------ source/vmax.c | 52 ---------- source/vmin.c | 52 ---------- source/vmtof.c | 51 --------- source/vnmax.c | 55 ---------- source/vpow.c | 60 ----------- source/vrms.c | 41 -------- source/vrmstodb.c | 54 ---------- source/vstd.c | 45 -------- source/vsum.c | 40 ------- source/vthreshold.c | 106 ------------------- source/vvconv.c | 151 --------------------------- source/vvminus.c | 142 ------------------------- source/vvplus.c | 142 ------------------------- threshold-help.pd | 50 +++++++++ threshold.c | 112 ++++++++++++++++++++ vabs-help.pd | 6 ++ vabs.c | 48 +++++++++ vclip-help.pd | 17 +++ vclip.c | 58 +++++++++++ vcog-help.pd | 21 ++++ vcog.c | 43 ++++++++ vdbtorms-help.pd | 9 ++ vdbtorms.c | 56 ++++++++++ vdelta-help.pd | 29 ++++++ vdelta.c | 75 ++++++++++++++ vfmod-help.pd | 17 +++ vfmod.c | 57 ++++++++++ vftom-help.pd | 9 ++ vftom.c | 49 +++++++++ vlavg-help.pd | 29 ++++++ vlavg.c | 86 ++++++++++++++++ vlmax-help.pd | 29 ++++++ vlmax.c | 86 ++++++++++++++++ vlmin-help.pd | 29 ++++++ vlmin.c | 86 ++++++++++++++++ vlrange-help.pd | 9 ++ vlrange.c | 99 ++++++++++++++++++ vmax-help.pd | 21 ++++ vmax.c | 52 ++++++++++ vmin-help.pd | 21 ++++ vmin.c | 52 ++++++++++ vmtof-help.pd | 9 ++ vmtof.c | 51 +++++++++ vnmax-help.pd | 9 ++ vnmax.c | 55 ++++++++++ vpow-help.pd | 15 +++ vpow.c | 60 +++++++++++ vrms-help.pd | 15 +++ vrms.c | 41 ++++++++ vrmstodb-help.pd | 9 ++ vrmstodb.c | 54 ++++++++++ vstd-help.pd | 15 +++ vstd.c | 45 ++++++++ vsum-help.pd | 13 +++ vsum.c | 40 +++++++ vthreshold-help.pd | 9 ++ vthreshold.c | 106 +++++++++++++++++++ vvconv-help.pd | 35 +++++++ vvconv.c | 151 +++++++++++++++++++++++++++ vvminus-help.pd | 23 +++++ vvminus.c | 142 +++++++++++++++++++++++++ vvplus-help.pd | 25 +++++ vvplus.c | 142 +++++++++++++++++++++++++ 175 files changed, 5409 insertions(+), 5076 deletions(-) create mode 100644 Makefile create mode 100644 SMLib-help.pd create mode 100644 SMLib.c create mode 100755 SMLib.dsp create mode 100755 SMLib.dsw create mode 100755 SMLib.opt create mode 100755 SMLib.plg create mode 100644 bp-help.pd create mode 100644 bp.c create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 decimator.c create mode 100644 defines.h create mode 100644 deltas-help.pd create mode 100644 deltas.c delete mode 100644 help/SMLib-help.pd delete mode 100644 help/bp-help.pd delete mode 100644 help/deltas-help.pd delete mode 100644 help/hip-help.pd delete mode 100644 help/hist-help.pd delete mode 100644 help/itov-help.pd delete mode 100644 help/lavg-help.pd delete mode 100644 help/lhist-help.pd delete mode 100644 help/lhisti-help.pd delete mode 100644 help/linspace-help.pd delete mode 100644 help/lmax-help.pd delete mode 100644 help/lmin-help.pd delete mode 100644 help/lrange-help.pd delete mode 100644 help/prevl-help.pd delete mode 100644 help/threshold-help.pd delete mode 100644 help/vabs-help.pd delete mode 100644 help/vclip-help.pd delete mode 100644 help/vcog-help.pd delete mode 100644 help/vdbtorms-help.pd delete mode 100644 help/vdelta-help.pd delete mode 100644 help/vfmod-help.pd delete mode 100644 help/vftom-help.pd delete mode 100644 help/vlavg-help.pd delete mode 100644 help/vlmax-help.pd delete mode 100644 help/vlmin-help.pd delete mode 100644 help/vmax-help.pd delete mode 100644 help/vmin-help.pd delete mode 100644 help/vmtof-help.pd delete mode 100644 help/vpow-help.pd delete mode 100644 help/vrms-help.pd delete mode 100644 help/vrmstodb-help.pd delete mode 100644 help/vstd-help.pd delete mode 100644 help/vsum-help.pd delete mode 100644 help/vvconv-help.pd delete mode 100644 help/vvminus-help.pd delete mode 100644 help/vvplus-help.pd create mode 100644 hip-help.pd create mode 100644 hip.c create mode 100644 hist-help.pd create mode 100644 hist.c create mode 100644 itov-help.pd create mode 100644 itov.c create mode 100644 lavg-help.pd create mode 100644 lavg.c create mode 100644 lhist-help.pd create mode 100644 lhist.c create mode 100644 lhisti-help.pd create mode 100644 lhisti.c create mode 100644 linspace-help.pd create mode 100644 linspace.c create mode 100644 lmax-help.pd create mode 100644 lmax.c create mode 100644 lmin-help.pd create mode 100644 lmin.c create mode 100644 lrange-help.pd create mode 100644 lrange.c create mode 100644 lstd-help.pd create mode 100644 lstd.c create mode 100644 prevl-help.pd create mode 100644 prevl.c create mode 100644 smlib-meta.pd delete mode 100644 source/SMLib.c delete mode 100755 source/SMLib.dsp delete mode 100755 source/SMLib.dsw delete mode 100755 source/SMLib.opt delete mode 100755 source/SMLib.plg delete mode 100644 source/bp.c delete mode 100644 source/decimator.c delete mode 100644 source/defines.h delete mode 100644 source/deltas.c delete mode 100644 source/hip.c delete mode 100644 source/hist.c delete mode 100644 source/itov.c delete mode 100644 source/lavg.c delete mode 100644 source/lhist.c delete mode 100644 source/lhisti.c delete mode 100644 source/linspace.c delete mode 100644 source/lmax.c delete mode 100644 source/lmin.c delete mode 100644 source/lrange.c delete mode 100644 source/lstd.c delete mode 100644 source/prevl.c delete mode 100644 source/threshold.c delete mode 100644 source/vabs.c delete mode 100644 source/vclip.c delete mode 100644 source/vcog.c delete mode 100644 source/vdbtorms.c delete mode 100644 source/vdelta.c delete mode 100644 source/vfmod.c delete mode 100644 source/vftom.c delete mode 100644 source/vlavg.c delete mode 100644 source/vlmax.c delete mode 100644 source/vlmin.c delete mode 100644 source/vlrange.c delete mode 100644 source/vmax.c delete mode 100644 source/vmin.c delete mode 100644 source/vmtof.c delete mode 100644 source/vnmax.c delete mode 100644 source/vpow.c delete mode 100644 source/vrms.c delete mode 100644 source/vrmstodb.c delete mode 100644 source/vstd.c delete mode 100644 source/vsum.c delete mode 100644 source/vthreshold.c delete mode 100644 source/vvconv.c delete mode 100644 source/vvminus.c delete mode 100644 source/vvplus.c create mode 100644 threshold-help.pd create mode 100644 threshold.c create mode 100644 vabs-help.pd create mode 100644 vabs.c create mode 100644 vclip-help.pd create mode 100644 vclip.c create mode 100644 vcog-help.pd create mode 100644 vcog.c create mode 100644 vdbtorms-help.pd create mode 100644 vdbtorms.c create mode 100644 vdelta-help.pd create mode 100644 vdelta.c create mode 100644 vfmod-help.pd create mode 100644 vfmod.c create mode 100644 vftom-help.pd create mode 100644 vftom.c create mode 100644 vlavg-help.pd create mode 100644 vlavg.c create mode 100644 vlmax-help.pd create mode 100644 vlmax.c create mode 100644 vlmin-help.pd create mode 100644 vlmin.c create mode 100644 vlrange-help.pd create mode 100644 vlrange.c create mode 100644 vmax-help.pd create mode 100644 vmax.c create mode 100644 vmin-help.pd create mode 100644 vmin.c create mode 100644 vmtof-help.pd create mode 100644 vmtof.c create mode 100644 vnmax-help.pd create mode 100644 vnmax.c create mode 100644 vpow-help.pd create mode 100644 vpow.c create mode 100644 vrms-help.pd create mode 100644 vrms.c create mode 100644 vrmstodb-help.pd create mode 100644 vrmstodb.c create mode 100644 vstd-help.pd create mode 100644 vstd.c create mode 100644 vsum-help.pd create mode 100644 vsum.c create mode 100644 vthreshold-help.pd create mode 100644 vthreshold.c create mode 100644 vvconv-help.pd create mode 100644 vvconv.c create mode 100644 vvminus-help.pd create mode 100644 vvminus.c create mode 100644 vvplus-help.pd create mode 100644 vvplus.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..deecc5d --- /dev/null +++ b/Makefile @@ -0,0 +1,235 @@ +# 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 = smlib +LIBRARY_VERSION = 0.12.1 + +# Next, add your .c source files to the SOURCES variable. The help files will +# be included automatically +SOURCES = bp.c decimator.c deltas.c hip.c hist.c itov.c lavg.c lhist.c lhisti.c linspace.c lmax.c lmin.c lrange.c lstd.c prevl.c threshold.c vabs.c vclip.c vcog.c vdbtorms.c vdelta.c vfmod.c vftom.c vlavg.c vlmax.c vlmin.c vlrange.c vmax.c vmin.c vmtof.c vnmax.c vpow.c vrms.c vrmstodb.c vstd.c vsum.c vthreshold.c vvconv.c vvminus.c vvplus.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 SMLib.c SMLib-help.pd SMLib.dsp SMLib.dsw SMLib.opt SMLib.plg + + +#------------------------------------------------------------------------------# +# +# 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 + + +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) + + +etags: + 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/SMLib-help.pd b/SMLib-help.pd new file mode 100644 index 0000000..d7be596 --- /dev/null +++ b/SMLib-help.pd @@ -0,0 +1,99 @@ +#N canvas 103 71 525 422 10; +#X obj 31 188 lmax; +#X obj 31 211 lmin; +#X obj 31 234 lrange; +#X obj 31 165 lavg; +#X obj 9 317 threshold; +#X text 89 188 leaky maximum; +#X text 89 213 leaky minimum; +#X text 90 237 leaky range; +#X text 89 164 leaky average; +#X text 92 316 hysteresis; +#X obj 31 257 lstd; +#X text 90 260 leaky standard deviation; +#X obj 26 421 hist; +#X text 88 421 histogram; +#X obj 26 444 lhist; +#X text 88 445 leaky histogram; +#X obj 9 293 decimator; +#X text 94 291 decimator; +#X obj 32 352 hip; +#X obj 32 375 bp; +#X text 83 751 vector addition; +#X text 83 774 vector substraction; +#X obj 25 797 vvconv; +#X text 83 797 vector convolution; +#X obj 24 590 vsum; +#X text 85 592 sum of elements; +#X obj 24 613 vcog; +#X text 85 613 center of gravity; +#X obj 24 636 vmax; +#X text 86 637 maximum and its location; +#X text 86 659 minimum and its location; +#X obj 24 659 vmin; +#X obj 27 1129 vlavg; +#X text 87 1131 leaky averages; +#X text 3 4 SMLib means Signal processing for Mapping; +#X text 435 1264 j#|@2002; +#X text 249 121 johannes.taelman@rug.ac.be; +#X text 283 102 enjoy!; +#X obj 27 1152 vlmax; +#X text 87 1154 leaky maxima; +#X obj 27 1175 vlmin; +#X text 87 1177 leaky minima; +#X obj 27 1198 vlrange; +#X text 87 1200 leaky ranges; +#X obj 27 1221 vdelta; +#X text 88 1223 differences between succesive vectors; +#X obj 25 820 vclip; +#X text 84 821 clip elements; +#X text 96 352 high pass filter; +#X text 97 375 band pass filter; +#X text 3 29 Its a collection of objects for the analysis of float +streams (for taking temporal context into account) \, vectors (lists +of floats) and vector streams (temporal context...). It is complementary +to the zexy and gem/markex library \, so have a look at those too. +; +#X obj 24 683 vrms; +#X text 84 686 root mean square; +#X obj 24 706 vstd; +#X text 83 708 standard deviation; +#X text 22 1044 there is also a [Clip] in cyclone (identical to vclip) +; +#X text 0 398 analyzing stream of floats (context) (vector output) +; +#X text 1 142 processing stream of floats (context) (float output) +; +#X text -3 567 immediate vector analysis (float output); +#X text -6 730 immediate vector processing (vector output); +#X text 22 1010 cfr. [.] in zexy; +#X text 22 1027 cfr. [v+] \, [v-] \, [v*] \, [v/] \, [vabs] in GEM/MarkEx +; +#X text -2 1108 vector stream processing (context) (vector output) +; +#X obj 25 843 vfmod; +#X text 83 845 floating point modulo; +#X obj 23 918 vmtof; +#X text 81 918 midi to frequency; +#X text 21 897 unit conversions; +#X obj 23 941 vftom; +#X text 81 941 frequency to midi; +#X obj 23 964 vdbtorms; +#X text 99 964 db to rms; +#X obj 23 987 vrmstodb; +#X text 99 987 rms to db; +#X obj 25 866 vpow; +#X obj 25 546 deltas; +#X text 83 867 power; +#X obj 26 466 lhisti; +#X text 88 467 leaky histogram without clipping input; +#X text 88 546 difference between current input and past inputs; +#X obj 26 520 prevl; +#X text 89 520 previous input values in a list; +#X text -3 1064 vector synthesis; +#X obj 23 1085 linspace; +#X text 98 1085 generates a vector with linear spaced floats; +#X obj 44 492 itov; +#X text 90 491 index to value (for histogram bins); +#X obj 25 751 vvplus; +#X obj 25 774 vvminus; diff --git a/SMLib.c b/SMLib.c new file mode 100644 index 0000000..baf4c8a --- /dev/null +++ b/SMLib.c @@ -0,0 +1,234 @@ +/* --------------------- SMLib ----------------------------- */ +/* + + Signal processing for Mapping + objects: + + float stream + - pid controller? + - deltas (generate difference vector between current values and values of the past) + vector + - vquant (quantizer with hysteresis) + - vv/ + - vv> + - vv< + - s2v (stream to vector, incl ola) + - v2s (vector to stream, incl ola) + + vector math + - vreverse + + - delread + - delwrite + - upsample + - fir + - autorescale +*/ + +#include "defines.h" + + +// in alphabetical order +extern void bp_setup(); +extern void decimator_setup(); +extern void deltas_setup(); +extern void hip_setup(); +extern void hist_setup(); +extern void itov_setup(); +extern void lavg_setup(); +extern void lhist_setup(); +extern void lhisti_setup(); +extern void linspace_setup(); +extern void lmax_setup(); +extern void lmin_setup(); +extern void lrange_setup(); +extern void lstd_setup(); +extern void prevl_setup(); +extern void threshold_setup(); +extern void vabs_setup(); +extern void vclip_setup(); +extern void vcog_setup(); +extern void vdbtorms_setup(); +extern void vdelta_setup(); +extern void vfmod_setup(); +extern void vftom_setup(); +extern void vlavg_setup(); +extern void vlmax_setup(); +extern void vlmin_setup(); +extern void vlrange_setup(); +extern void vmax_setup(); +extern void vmin_setup(); +extern void vmtof_setup(); +extern void vpow_setup(); +extern void vrms_setup(); +extern void vrmstodb_setup(); +extern void vstd_setup(); +extern void vsum_setup(); +extern void vthreshold_setup(); +extern void vvconv_setup(); +extern void vvminus_setup(); +extern void vvplus_setup(); + +static t_class *SMLib_class; + +typedef struct _lstd +{ + t_object x_obj; +} t_SMLib; + +static void SMLib_help(t_SMLib *x) +{ + /* + */ + post(""); + post(""); + post(" .........................................................."); + post(" . SMLib ."); + post(" . Signal processing for Mapping ."); + post(" . v0.12 24/11/2002 ."); + post(" .........................................................."); + post(" . processing stream of floats (context) (float output) ."); + post(" . ."); + post(" . lavg leaky average ."); + post(" . lmax leaky maximum ."); + post(" . lmin leaky minimum ."); + post(" . lrange leaky range ."); + post(" u lstd leaky standard deviation ."); + post(" u decimator passes 1 in n input values ."); + post(" . threshold detection with hysteresis ."); + post(" . hip first order high-pass filter ."); + post(" . bp second order (resonant) high-pass filter ."); + post(" .........................................................."); + post(" . analyzing stream of floats (vector output) ."); + post(" . ."); + post(" . hist histogram ."); + post(" . lhist leaky histogram, clips samples ."); + post(" . lhisti leaky histogram, ignore samples ."); + post(" . outside bins ."); + post(" . itov bin index to value (for the histograms ."); + post(" . prevl previous floats in a list ."); + post(" . deltas difference between last float and ."); + post(" . previous floats ."); +// post(" o filterbank lineairly spaced set of bandpass filters ."); + post(" .........................................................."); + post(" . immediate vector analysis (float output) ."); + post(" . ."); + post(" . vsum sum of vector elements ."); + post(" . vcog center of gravity ."); + post(" . vmax maximum and its location ."); + post(" . vmin minimum and its location ."); + post(" . vrms root mean square ."); + post(" . vstd standard deviation ."); + post(" .........................................................."); + post(" . vector processors (vector output) ."); + post(" . ."); + post(" . vv+ vector addition ."); + post(" . vv- vector substraction ."); + post(" . vvconv vector convolution ."); + post(" . vclip clip elements ."); + post(" . vfmod floating point modulo ."); + post(" . vpow power ."); + post(" . vthreshold detections with hysteresises ."); + post(" . ."); + post(" . unit conversions on vectors ."); + post(" . ."); + post(" . vftom frequency to midi ."); + post(" . vmtof midi to frequency ."); + post(" . vdbtorms dB to rms ."); + post(" . vrmstodb rms to dB ."); + post(" .........................................................."); + post(" . vector synthesis (vector output) ."); + post(" . ."); + post(" . linspace linearly spaced vector ."); +// post(" o logspace logarithmically spaced vector ."); +// post(" o rand uniformly distributed random vector ."); +// post(" o randn normally distributed random vector ."); + post(" .........................................................."); + post(" . vector stream processing (vector output) (context) ."); + post(" . ."); + post(" . vlavg leaky averages ."); + post(" . vlmax leaky maxima ."); + post(" . vlmin leaky minima ."); + post(" . vlrange leaky ranges ."); + post(" . vdelta difference between successive vectors ."); + post(" .........................................................."); +// post(" . o = future additions ."); +// post(" . e = experimental ."); + post(" . u = undocumented ."); + post(" . j#|@ = johannes.taelman@rug.ac.be ."); + post(" .........................................................."); + post(""); + post(""); +} + +static void *SMLib_new() +{ + t_SMLib *x=(t_SMLib *)pd_new(SMLib_class); + return (void *)x; +} + +#ifdef WIN32 +__declspec(dllexport) void __cdecl SMLib_setup( void) +#else +void SMLib_setup( void) +#endif +{ + // dummy object for help-system + SMLib_class = class_new(gensym("SMLib"), + (t_newmethod)SMLib_new, 0, + sizeof(t_SMLib), + CLASS_DEFAULT, + 0); + class_addbang(SMLib_class, (t_method)SMLib_help); + class_addmethod(SMLib_class, (t_method)SMLib_help, gensym("help"),0); + + // real objects in alphabetical order + bp_setup(); + decimator_setup(); + deltas_setup(); + hip_setup(); + hist_setup(); + itov_setup(); + lavg_setup(); + lhist_setup(); + lhisti_setup(); + linspace_setup(); + lmax_setup(); + lmin_setup(); + lrange_setup(); + lstd_setup(); + prevl_setup(); + threshold_setup(); + vabs_setup(); + vclip_setup(); + vcog_setup(); + vdbtorms_setup(); + vdelta_setup(); + vfmod_setup(); + vftom_setup(); + vlavg_setup(); + vlmax_setup(); + vlmin_setup(); + vlrange_setup(); + vmax_setup(); + vmin_setup(); + vmtof_setup(); + vpow_setup(); + vrms_setup(); + vrmstodb_setup(); + vstd_setup(); + vsum_setup(); + vthreshold_setup(); + vvconv_setup(); + vvminus_setup(); + vvplus_setup(); + + post(""); + post(" .........................................................."); + post(" . SMLib ."); + post(" . Signal processing for Mapping ."); + post(" . v0.12 24/11/2002 ."); + post(" .........................................................."); + post(""); + +} diff --git a/SMLib.dsp b/SMLib.dsp new file mode 100755 index 0000000..35c2ab8 --- /dev/null +++ b/SMLib.dsp @@ -0,0 +1,275 @@ +# Microsoft Developer Studio Project File - Name="SMLib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=SMLib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "SMLib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "SMLib.mak" CFG="SMLib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "SMLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "SMLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "SMLib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x813 /d "NDEBUG" +# ADD RSC /l 0x813 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /machine:I386 + +!ELSEIF "$(CFG)" == "SMLib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x813 /d "_DEBUG" +# ADD RSC /l 0x813 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "SMLib - Win32 Release" +# Name "SMLib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\bp.c +# End Source File +# Begin Source File + +SOURCE=.\decimator.c +# End Source File +# Begin Source File + +SOURCE=.\deltas.c +# End Source File +# Begin Source File + +SOURCE=.\hip.c +# End Source File +# Begin Source File + +SOURCE=.\hist.c +# End Source File +# Begin Source File + +SOURCE=.\itov.c +# End Source File +# Begin Source File + +SOURCE=.\lavg.c +# End Source File +# Begin Source File + +SOURCE=.\lhist.c +# End Source File +# Begin Source File + +SOURCE=.\lhisti.c +# End Source File +# Begin Source File + +SOURCE=.\linspace.c +# End Source File +# Begin Source File + +SOURCE=.\lmax.c +# End Source File +# Begin Source File + +SOURCE=.\lmin.c +# End Source File +# Begin Source File + +SOURCE=.\lrange.c +# End Source File +# Begin Source File + +SOURCE=.\lstd.c +# End Source File +# Begin Source File + +SOURCE=.\prevl.c +# End Source File +# Begin Source File + +SOURCE=.\SMLib.c +# End Source File +# Begin Source File + +SOURCE=.\threshold.c +# End Source File +# Begin Source File + +SOURCE=.\vabs.c +# End Source File +# Begin Source File + +SOURCE=.\vclip.c +# End Source File +# Begin Source File + +SOURCE=.\vcog.c +# End Source File +# Begin Source File + +SOURCE=.\vdbtorms.c +# End Source File +# Begin Source File + +SOURCE=.\vdelta.c +# End Source File +# Begin Source File + +SOURCE=.\vfmod.c +# End Source File +# Begin Source File + +SOURCE=.\vftom.c +# End Source File +# Begin Source File + +SOURCE=.\vlavg.c +# End Source File +# Begin Source File + +SOURCE=.\vlmax.c +# End Source File +# Begin Source File + +SOURCE=.\vlmin.c +# End Source File +# Begin Source File + +SOURCE=.\vlrange.c +# End Source File +# Begin Source File + +SOURCE=.\vmax.c +# End Source File +# Begin Source File + +SOURCE=.\vmin.c +# End Source File +# Begin Source File + +SOURCE=.\vmtof.c +# End Source File +# Begin Source File + +SOURCE=.\vnmax.c +# End Source File +# Begin Source File + +SOURCE=.\vpow.c +# End Source File +# Begin Source File + +SOURCE=.\vrms.c +# End Source File +# Begin Source File + +SOURCE=.\vrmstodb.c +# End Source File +# Begin Source File + +SOURCE=.\vstd.c +# End Source File +# Begin Source File + +SOURCE=.\vsum.c +# End Source File +# Begin Source File + +SOURCE=.\vthreshold.c +# End Source File +# Begin Source File + +SOURCE=.\vvconv.c +# End Source File +# Begin Source File + +SOURCE=.\vvminus.c +# End Source File +# Begin Source File + +SOURCE=.\vvplus.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\defines.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\readme.txt +# End Source File +# End Target +# End Project diff --git a/SMLib.dsw b/SMLib.dsw new file mode 100755 index 0000000..0428bd3 --- /dev/null +++ b/SMLib.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "SMLib"=.\SMLib.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/SMLib.opt b/SMLib.opt new file mode 100755 index 0000000..685315a Binary files /dev/null and b/SMLib.opt differ diff --git a/SMLib.plg b/SMLib.plg new file mode 100755 index 0000000..c75a641 --- /dev/null +++ b/SMLib.plg @@ -0,0 +1,153 @@ + + +
+

Build Log

+

+--------------------Configuration: SMLib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" with contents +[ +/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /Fp"Release/SMLib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"D:\devel\SMLib\bp.c" +"D:\devel\SMLib\decimator.c" +"D:\devel\SMLib\deltas.c" +"D:\devel\SMLib\hip.c" +"D:\devel\SMLib\hist.c" +"D:\devel\SMLib\itov.c" +"D:\devel\SMLib\lavg.c" +"D:\devel\SMLib\lhist.c" +"D:\devel\SMLib\lhisti.c" +"D:\devel\SMLib\linspace.c" +"D:\devel\SMLib\lmax.c" +"D:\devel\SMLib\lmin.c" +"D:\devel\SMLib\lrange.c" +"D:\devel\SMLib\lstd.c" +"D:\devel\SMLib\prevl.c" +"D:\devel\SMLib\SMLib.c" +"D:\devel\SMLib\threshold.c" +"D:\devel\SMLib\vabs.c" +"D:\devel\SMLib\vclip.c" +"D:\devel\SMLib\vcog.c" +"D:\devel\SMLib\vdbtorms.c" +"D:\devel\SMLib\vdelta.c" +"D:\devel\SMLib\vfmod.c" +"D:\devel\SMLib\vftom.c" +"D:\devel\SMLib\vlavg.c" +"D:\devel\SMLib\vlmax.c" +"D:\devel\SMLib\vlmin.c" +"D:\devel\SMLib\vlrange.c" +"D:\devel\SMLib\vmax.c" +"D:\devel\SMLib\vmin.c" +"D:\devel\SMLib\vmtof.c" +"D:\devel\SMLib\vnmax.c" +"D:\devel\SMLib\vpow.c" +"D:\devel\SMLib\vrms.c" +"D:\devel\SMLib\vrmstodb.c" +"D:\devel\SMLib\vstd.c" +"D:\devel\SMLib\vsum.c" +"D:\devel\SMLib\vthreshold.c" +"D:\devel\SMLib\vvconv.c" +"D:\devel\SMLib\vvminus.c" +"D:\devel\SMLib\vvplus.c" +] +Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" +Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /incremental:no /pdb:"Release/SMLib.pdb" /machine:I386 /out:"Release/SMLib.dll" /implib:"Release/SMLib.lib" +.\Release\bp.obj +.\Release\decimator.obj +.\Release\deltas.obj +.\Release\hip.obj +.\Release\hist.obj +.\Release\itov.obj +.\Release\lavg.obj +.\Release\lhist.obj +.\Release\lhisti.obj +.\Release\linspace.obj +.\Release\lmax.obj +.\Release\lmin.obj +.\Release\lrange.obj +.\Release\lstd.obj +.\Release\prevl.obj +.\Release\SMLib.obj +.\Release\threshold.obj +.\Release\vabs.obj +.\Release\vclip.obj +.\Release\vcog.obj +.\Release\vdbtorms.obj +.\Release\vdelta.obj +.\Release\vfmod.obj +.\Release\vftom.obj +.\Release\vlavg.obj +.\Release\vlmax.obj +.\Release\vlmin.obj +.\Release\vlrange.obj +.\Release\vmax.obj +.\Release\vmin.obj +.\Release\vmtof.obj +.\Release\vnmax.obj +.\Release\vpow.obj +.\Release\vrms.obj +.\Release\vrmstodb.obj +.\Release\vstd.obj +.\Release\vsum.obj +.\Release\vthreshold.obj +.\Release\vvconv.obj +.\Release\vvminus.obj +.\Release\vvplus.obj +] +Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" +

Output Window

+Compiling... +bp.c +decimator.c +deltas.c +hip.c +hist.c +itov.c +lavg.c +lhist.c +lhisti.c +linspace.c +lmax.c +lmin.c +lrange.c +lstd.c +prevl.c +SMLib.c +threshold.c +vabs.c +vclip.c +vcog.c +vdbtorms.c +vdelta.c +vfmod.c +vftom.c +vlavg.c +vlmax.c +vlmin.c +vlrange.c +vmax.c +vmin.c +vmtof.c +vnmax.c +vpow.c +vrms.c +vrmstodb.c +vstd.c +vsum.c +vthreshold.c +vvconv.c +vvminus.c +vvplus.c +Linking... + Creating library Release/SMLib.lib and object Release/SMLib.exp + + + +

Results

+SMLib.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/bp-help.pd b/bp-help.pd new file mode 100644 index 0000000..eedc01a --- /dev/null +++ b/bp-help.pd @@ -0,0 +1,35 @@ +#N canvas 114 43 428 284 10; +#X floatatom 12 141 5 0 0; +#X obj 12 118 float; +#X obj 12 95 metro 100; +#X obj 12 54 loadbang; +#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 12700 1; +#X text 349 255 j#|@2002; +#X obj 367 233 SMLib-help; +#X text 13 7 bp: bandpass filter on float stream; +#X floatatom 138 133 0 0 0; +#X msg 106 110 clear; +#X text 156 109 <-- reinitialize internal state; +#X text 170 134 <-- center frequency; +#X floatatom 187 155 0 0 0; +#X text 219 156 <-- Q; +#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 7974 1; +#X floatatom 17 237 5 0 0; +#X text 11 25 the non-audio version of bp~; +#X text 262 76 <-- swing!; +#X obj 19 182 bp 0.07 5; +#X connect 1 0 0 0; +#X connect 1 0 19 0; +#X connect 2 0 1 0; +#X connect 3 0 4 0; +#X connect 4 0 2 0; +#X connect 5 0 1 1; +#X connect 9 0 19 1; +#X connect 10 0 19 0; +#X connect 13 0 19 2; +#X connect 15 0 16 0; +#X connect 19 0 15 0; diff --git a/bp.c b/bp.c new file mode 100644 index 0000000..d21bc19 --- /dev/null +++ b/bp.c @@ -0,0 +1,123 @@ +#include "defines.h" + +/*--------------- bp ---------------*/ + +typedef struct bpctl +{ + float c_x1; + float c_x2; + float c_coef1; + float c_coef2; + float c_gain; +} t_bpctl; + +typedef struct bp +{ + t_object x_obj; + float x_freq; + float x_q; + t_bpctl x_cspace; + t_bpctl *x_ctl; + float x_f; +} t_bp; + +t_class *bp_class; + +static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q); + +static void *bp_new(t_floatarg f, t_floatarg q) +{ + t_bp *x = (t_bp *)pd_new(bp_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2")); + outlet_new(&x->x_obj, gensym("float")); + x->x_ctl = &x->x_cspace; + x->x_cspace.c_x1 = 0; + x->x_cspace.c_x2 = 0; + bp_docoef(x, f, q); + x->x_f = 0; + return (x); +} + +static float bp_qcos(float f) +{ + if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f) + { + float g = f*f; + return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5f) + 1); + } + else return (0); +} + +static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q) +{ + float r, oneminusr, omega; + if (f < 0.0001f) f = 0.0001f; + if (q < 0) q = 0; + x->x_freq = f; + x->x_q = q; + omega = f * (2.0f * 3.14159f); + if (q < 0.001) oneminusr = 1.0f; + else oneminusr = omega/q; + if (oneminusr > 1.0f) oneminusr = 1.0f; + r = 1.0f - oneminusr; + x->x_ctl->c_coef1 = 2.0f * bp_qcos(omega) * r; + x->x_ctl->c_coef2 = - r * r; + x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega); + /* post("r %f, omega %f, coef1 %f, coef2 %f", + r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */ +} + +static void bp_ft1(t_bp *x, t_floatarg f) +{ + bp_docoef(x, f, x->x_q); +} + +static void bp_ft2(t_bp *x, t_floatarg q) +{ + bp_docoef(x, x->x_freq, q); +} + +static void bp_clear(t_bp *x, t_floatarg q) +{ + x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0; +} + +static void bp_perform(t_bp *x, t_float in) +{ + float out; + t_bpctl *c = x->x_ctl; + float last = c->c_x1; + float prev = c->c_x2; + float coef1 = c->c_coef1; + float coef2 = c->c_coef2; + float gain = c->c_gain; + + float output = in + coef1 * last + coef2 * prev; + out = gain * output; + + prev = last; + last = output; + + /* NAN protect */ + if (!((last <= 0) || (last >= 0))) + last = 0; + if (!((prev <= 0) || (prev >= 0))) + prev = 0; + c->c_x1 = last; + c->c_x2 = prev; + + outlet_float(x->x_obj.ob_outlet, out); +} + +void bp_setup(void) +{ + bp_class = class_new(gensym("bp"), (t_newmethod)bp_new, 0, + sizeof(t_bp), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addfloat(bp_class, (t_method)bp_perform); + class_addmethod(bp_class, (t_method)bp_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(bp_class, (t_method)bp_ft2, + gensym("ft2"), A_FLOAT, 0); + class_addmethod(bp_class, (t_method)bp_clear, gensym("clear"), 0); +} diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..c241b9c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pd-smlib (0.12-1) unstable; urgency=low + + * Initial release (Closes: #nnnn) + + -- Hans-Christoph Steiner Thu, 21 Jan 2010 23:27:04 -0500 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..c60a1e7 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: pd-smlib +Section: sound +Priority: optional +Maintainer: Paul Brossier +Build-Depends: debhelper (>= 7.0.50~), puredata +Standards-Version: 3.8.3 +Homepage: http://puredata.info + +Package: pd-smlib +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, pd +Description: signal processing library for mapping + SMLib is an external objects library for PD (pure data). It complements PD + with a set of objects for vector processing, vector analysis, vector + synthesis, number stream analysis, number stream filters. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..8572e83 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,13 @@ +Debianized-By: Hans-Christoph Steiner +Debianized-Date: Tue, 9 Feb 2010 17:14:25 -0400 +Files: * +Copyright: Copyright 2002 Johannes Taelman + +License: GPL-2+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + On Debian systems, the complete text of the GNU General Public License + version 2 can be found in file "/usr/share/common-licenses/GPL-2". diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..7505a39 --- /dev/null +++ b/debian/rules @@ -0,0 +1,16 @@ +#!/usr/bin/make -f + +LIBRARY_NAME = smlib +PACKAGE = pd-$(LIBRARY_NAME) +pkglibdir = /usr/lib/pd/extra + +%: + dh $@ + +override_dh_auto_install: + make DESTDIR=$(CURDIR)/debian/$(PACKAGE) pkglibdir=$(pkglibdir) install + +override_dh_shlibdeps: + dpkg-shlibdeps $(CURDIR)/debian/$(PACKAGE)$(pkglibdir)/$(LIBRARY_NAME)/*.pd_linux \ + -T$(CURDIR)/debian/$(PACKAGE).substvars + diff --git a/decimator.c b/decimator.c new file mode 100644 index 0000000..d7f93f3 --- /dev/null +++ b/decimator.c @@ -0,0 +1,66 @@ +#include "defines.h" + +/*--------------- decimator ---------------*/ + +static t_class *decimator_class; + +typedef struct _decimator +{ + t_object x_obj; + int m_state; + int m_factor; +} t_decimator; + +static void decimator_perform(t_decimator *x, t_float in) +{ + if (!x->m_state) + { + outlet_float(x->x_obj.ob_outlet, in); + x->m_state=x->m_factor; + } + else + { + x->m_state--; + } + +} + +static void decimator_setFactor(t_decimator *x, t_float factor) +{ + x->m_factor=(int)factor - 1; +} + +static void decimator_clear(t_decimator *x) +{ + x->m_state=0; +} + + +static void *decimator_new(t_float factor) +{ + + t_decimator *x=(t_decimator *)pd_new(decimator_class); + outlet_new(&x->x_obj, gensym("float")); + + if (factor<1) factor=2; + + decimator_setFactor(x, factor); + decimator_clear(x); + return (void *)x; +} + + +void decimator_setup(void) +{ + decimator_class = class_new(gensym("decimator"), + (t_newmethod)decimator_new, 0, + sizeof(t_decimator), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(decimator_class, (t_method)decimator_perform); + class_addmethod(decimator_class, (t_method)decimator_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(decimator_class, (t_method)decimator_setFactor, + gensym("factor"), A_DEFFLOAT, NULL); +} + diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..093a477 --- /dev/null +++ b/defines.h @@ -0,0 +1,17 @@ +#include +#include +#define MAXFLOAT 1e18f; +#define LOGTEN 2.302585092994 + +/* NT and OSX don't appear to have single-precision ANSI math */ +#if defined(_WIN32) || defined(__APPLE__) +#define sinf sin +#define cosf cos +#define atanf atan +#define atan2f atan2 +#define sqrtf sqrt +#define logf log +#define expf exp +#define fabsf fabs +#define powf pow +#endif diff --git a/deltas-help.pd b/deltas-help.pd new file mode 100644 index 0000000..9034308 --- /dev/null +++ b/deltas-help.pd @@ -0,0 +1,34 @@ +#N canvas 553 310 489 262 10; +#X text 390 239 j#|@2002; +#X obj 412 217 SMLib-help; +#X floatatom 14 74 5 0 0; +#X obj 12 165 print deltas; +#X floatatom 68 108 5 0 0; +#X floatatom 120 107 5 0 0; +#X obj 24 104 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 12 138 deltas 1 10 10; +#X obj 14 54 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 9 4 deltas: generates vector with differences between last +input and past inputs; +#X text 9 186 x(i)-x(i-a); +#X text 9 200 x(i)-x(i-(a+1)); +#X text 9 214 x(i)-x(i-(a+2)); +#X text 9 240 x(i)-x(i-(b)); +#X text 7 225 ...; +#X text 153 137 [deltas a b c]; +#X text 120 86 b; +#X text 66 87 a; +#X text 152 183 requires b<=c; +#X text 152 167 c = buffer size; +#X text 35 50 x(i); +#X msg 79 57 clear; +#X connect 2 0 6 0; +#X connect 2 0 7 0; +#X connect 4 0 7 1; +#X connect 5 0 7 2; +#X connect 6 0 7 0; +#X connect 7 0 3 0; +#X connect 8 0 2 0; +#X connect 21 0 7 0; diff --git a/deltas.c b/deltas.c new file mode 100644 index 0000000..edc3cb0 --- /dev/null +++ b/deltas.c @@ -0,0 +1,181 @@ +#include "defines.h" + +/*--------------- deltas ---------------*/ + +static t_class *deltas_class; + +typedef struct _deltas +{ + t_object x_obj; + float m_lo; + float m_hi; + int m_buffer_size; + int m_buffer_index; + float *m_buffer; // circular buffer +} t_deltas; + + +static void deltas_perform_float(t_deltas *x, t_float f) +{ + int index; + index=x->m_buffer_index+1; + index=(index==x->m_buffer_size)?0:index; + x->m_buffer_index=index; + x->m_buffer[index]=f; +} + +static void deltas_bang(t_deltas *x) +{ + int lo,hi,n,index,size; + t_atom *ap,*app; + float last; + float *buffer, *bp; + + lo=(int)x->m_lo; + hi=(int)x->m_hi; + + n=hi-lo; + size=x->m_buffer_size; + index=x->m_buffer_index; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + buffer=x->m_buffer; + last=buffer[index]; + bp=buffer+index-lo; + bp=(bp>=buffer)?bp:bp+size; // wrap + + if (bp-buffer>=n) + { // no wrap-around needed + index=n; + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } +// post("not wrapped, app-ap=%i",app-ap); + } + else // need to wrap + { + int ps, nn; + ps = bp-buffer; + nn=n; +// post(" nn=%i",nn); + for(;ps>=0;ps--) // don't we miss one sample in signal??? + { +// post("ps=%i",ps); + SETFLOAT(app, last-buffer[ps]); + app++; + nn--; + } + ps=size-1; +// post(" nn=%i",nn); + for(;nn>0;nn--) + { +// post("ps=%i",ps); + SETFLOAT(app, last-buffer[ps--]); + app++; + } + +/* + int i2; + index=bp-buffer; + i2=index; + post("first part %i",index); + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } + index=n-i2; + post("2nd part %i",index); + bp=buffer+size-1; + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } +*/ +// post("wrapped, app-ap=%i",app-ap); + } + + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void deltas_clear(t_deltas *x) +{ + int i,s; + float *f; + f=x->m_buffer; + s=x->m_buffer_size; + for (i=0;isize) + { + post("deltas: higher bound cannot be higher than the buffer size..."); + hi=size; + } + if (lo<0) + { + post("deltas: lower bound cannot be negative..."); + lo=0; + } + if (hi<1) + { + post("deltas: higher bound cannot be smaller than one..."); + hi=1; + } + if (hi<=lo) + { + post("deltas: higher bound must be higher than lower bound..."); + lo=hi-1.0f; + } + + freebytes(x->m_buffer, x->m_buffer_size); + + x->m_hi=(float)((int)hi); + x->m_lo=(float)((int)lo); + x->m_buffer_size=(int)size; + x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + deltas_clear(x); + x->m_buffer_index=0; +} + +static void *deltas_new(t_float lo, t_float hi, t_float size) +{ + t_deltas *x=(t_deltas *)pd_new(deltas_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_buffer_size=0; + x->m_buffer=0; + deltas_set(x, lo, hi, size); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + return (void *)x; +} + +static void deltas_free(t_deltas *x) +{ + freebytes(x->m_buffer, x->m_buffer_size); +} + +void deltas_setup(void) +{ + deltas_class = class_new(gensym("deltas"), + (t_newmethod)deltas_new, (t_method)deltas_free, + sizeof(t_deltas), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(deltas_class, (t_method)deltas_clear, gensym("clear"),0); + class_addfloat(deltas_class, (t_method)deltas_perform_float); + class_addbang(deltas_class, (t_method)deltas_bang); +} + diff --git a/help/SMLib-help.pd b/help/SMLib-help.pd deleted file mode 100644 index ea87988..0000000 --- a/help/SMLib-help.pd +++ /dev/null @@ -1,103 +0,0 @@ -#N canvas 97 25 525 422 10; -#X obj 31 188 lmax; -#X obj 31 211 lmin; -#X obj 31 234 lrange; -#X obj 31 165 lavg; -#X obj 9 317 threshold; -#X text 89 188 leaky maximum; -#X text 89 213 leaky minimum; -#X text 90 237 leaky range; -#X text 89 164 leaky average; -#X text 92 316 hysteresis; -#X obj 31 257 lstd; -#X text 90 260 leaky standard deviation; -#X obj 26 421 hist; -#X text 88 421 histogram; -#X obj 26 444 lhist; -#X text 88 445 leaky histogram; -#X obj 9 293 decimator; -#X text 94 291 decimator; -#X obj 32 352 hip; -#X obj 32 375 bp; -#X obj 25 751 vv+; -#X text 83 751 vector addition; -#X text 83 774 vector substraction; -#X obj 25 797 vvconv; -#X text 83 797 vector convolution; -#X obj 24 590 vsum; -#X text 85 592 sum of elements; -#X obj 24 613 vcog; -#X text 85 613 center of gravity; -#X obj 24 636 vmax; -#X text 86 637 maximum and its location; -#X text 86 659 minimum and its location; -#X obj 24 659 vmin; -#X obj 27 1129 vlavg; -#X text 87 1131 leaky averages; -#X text 3 4 SMLib means Signal processing for Mapping; -#X text 435 1264 j#|@2002; -#X text 249 121 johannes.taelman@rug.ac.be; -#X text 283 102 enjoy!; -#X obj 27 1152 vlmax; -#X text 87 1154 leaky maxima; -#X obj 27 1175 vlmin; -#X text 87 1177 leaky minima; -#X obj 27 1198 vlrange; -#X text 87 1200 leaky ranges; -#X obj 27 1221 vdelta; -#X text 88 1223 differences between succesive vectors; -#X obj 25 820 vclip; -#X text 84 821 clip elements; -#X text 96 352 high pass filter; -#X text 97 375 band pass filter; -#X text 3 29 Its a collection of objects for the analysis of float -streams (for taking temporal context into account) \, vectors (lists -of floats) and vector streams (temporal context...). It is complementary -to the zexy and gem/markex library \, so have a look at those too. -; -#X obj 25 774 vv-; -#X obj 24 683 vrms; -#X text 84 686 root mean square; -#X obj 24 706 vstd; -#X text 83 708 standard deviation; -#X text 22 1044 there is also a [Clip] in cyclone (identical to vclip) -; -#X text 0 398 analyzing stream of floats (context) (vector output) -; -#X text 1 142 processing stream of floats (context) (float output) -; -#X text -3 567 immediate vector analysis (float output); -#X text -6 730 immediate vector processing (vector output); -#X text 22 1010 cfr. [.] in zexy; -#X text 22 1027 cfr. [v+] \, [v-] \, [v*] \, [v/] \, [vabs] in GEM/MarkEx -; -#X text -2 1108 vector stream processing (context) (vector output) -; -#X obj 25 843 vfmod; -#X text 83 845 floating point modulo; -#X obj 23 918 vmtof; -#X text 81 918 midi to frequency; -#X text 21 897 unit conversions; -#X obj 23 941 vftom; -#X text 81 941 frequency to midi; -#X obj 23 964 vdbtorms; -#X text 99 964 db to rms; -#X obj 23 987 vrmstodb; -#X text 99 987 rms to db; -#X obj 25 866 vpow; -#X obj 25 546 deltas; -#X text 83 867 power; -#X obj 26 466 lhisti; -#X text 88 467 leaky histogram without clipping input; -#X text 88 546 difference between current input and past inputs; -#X obj 455 1243 SMLib-help; -#X obj 472 1224 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 --1 -1; -#X obj 26 520 prevl; -#X text 89 520 previous input values in a list; -#X text -3 1064 vector synthesis; -#X obj 23 1085 linspace; -#X text 98 1085 generates a vector with linear spaced floats; -#X obj 44 492 itov; -#X text 90 491 index to value (for histogram bins); -#X connect 83 0 82 0; diff --git a/help/bp-help.pd b/help/bp-help.pd deleted file mode 100644 index eedc01a..0000000 --- a/help/bp-help.pd +++ /dev/null @@ -1,35 +0,0 @@ -#N canvas 114 43 428 284 10; -#X floatatom 12 141 5 0 0; -#X obj 12 118 float; -#X obj 12 95 metro 100; -#X obj 12 54 loadbang; -#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 -; -#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 12700 1; -#X text 349 255 j#|@2002; -#X obj 367 233 SMLib-help; -#X text 13 7 bp: bandpass filter on float stream; -#X floatatom 138 133 0 0 0; -#X msg 106 110 clear; -#X text 156 109 <-- reinitialize internal state; -#X text 170 134 <-- center frequency; -#X floatatom 187 155 0 0 0; -#X text 219 156 <-- Q; -#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 7974 1; -#X floatatom 17 237 5 0 0; -#X text 11 25 the non-audio version of bp~; -#X text 262 76 <-- swing!; -#X obj 19 182 bp 0.07 5; -#X connect 1 0 0 0; -#X connect 1 0 19 0; -#X connect 2 0 1 0; -#X connect 3 0 4 0; -#X connect 4 0 2 0; -#X connect 5 0 1 1; -#X connect 9 0 19 1; -#X connect 10 0 19 0; -#X connect 13 0 19 2; -#X connect 15 0 16 0; -#X connect 19 0 15 0; diff --git a/help/deltas-help.pd b/help/deltas-help.pd deleted file mode 100644 index 9034308..0000000 --- a/help/deltas-help.pd +++ /dev/null @@ -1,34 +0,0 @@ -#N canvas 553 310 489 262 10; -#X text 390 239 j#|@2002; -#X obj 412 217 SMLib-help; -#X floatatom 14 74 5 0 0; -#X obj 12 165 print deltas; -#X floatatom 68 108 5 0 0; -#X floatatom 120 107 5 0 0; -#X obj 24 104 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X obj 12 138 deltas 1 10 10; -#X obj 14 54 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 9 4 deltas: generates vector with differences between last -input and past inputs; -#X text 9 186 x(i)-x(i-a); -#X text 9 200 x(i)-x(i-(a+1)); -#X text 9 214 x(i)-x(i-(a+2)); -#X text 9 240 x(i)-x(i-(b)); -#X text 7 225 ...; -#X text 153 137 [deltas a b c]; -#X text 120 86 b; -#X text 66 87 a; -#X text 152 183 requires b<=c; -#X text 152 167 c = buffer size; -#X text 35 50 x(i); -#X msg 79 57 clear; -#X connect 2 0 6 0; -#X connect 2 0 7 0; -#X connect 4 0 7 1; -#X connect 5 0 7 2; -#X connect 6 0 7 0; -#X connect 7 0 3 0; -#X connect 8 0 2 0; -#X connect 21 0 7 0; diff --git a/help/hip-help.pd b/help/hip-help.pd deleted file mode 100644 index 49587c5..0000000 --- a/help/hip-help.pd +++ /dev/null @@ -1,32 +0,0 @@ -#N canvas 114 43 430 286 10; -#X floatatom 12 141 5 0 0; -#X obj 12 118 float; -#X obj 12 95 metro 100; -#X obj 12 54 loadbang; -#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 -; -#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 12700 1; -#X text 349 255 j#|@2002; -#X obj 367 233 SMLib-help; -#X floatatom 138 133 0 0 0; -#X msg 106 110 clear; -#X text 156 109 <-- reinitialize internal state; -#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 6350 1; -#X floatatom 17 237 5 0 0; -#X text 262 76 <-- swing!; -#X text 13 7 hip: highpass filter on float stream; -#X text 11 25 the non-audio version of hip~; -#X obj 19 182 hip 0.05; -#X text 170 134 <-- cutoff frequency; -#X connect 1 0 0 0; -#X connect 1 0 16 0; -#X connect 2 0 1 0; -#X connect 3 0 4 0; -#X connect 4 0 2 0; -#X connect 5 0 1 1; -#X connect 8 0 16 1; -#X connect 9 0 16 0; -#X connect 11 0 12 0; -#X connect 16 0 11 0; diff --git a/help/hist-help.pd b/help/hist-help.pd deleted file mode 100644 index fd3984a..0000000 --- a/help/hist-help.pd +++ /dev/null @@ -1,44 +0,0 @@ -#N canvas 678 207 414 422 10; -#X text 331 381 j#|@2002; -#X text 351 362 SMLib-help; -#X text 14 7 hist: histograms; -#X obj 2 354 print; -#X obj 11 181 random 10; -#X obj 11 162 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X msg 129 177 absolute; -#X msg 129 205 relative; -#X msg 276 177 clear; -#X text 128 156 generate output; -#X text 275 159 reinit; -#X text 31 160 feed data; -#X obj 2 317 hist 0 10 10; -#X obj 62 347 vsum; -#X floatatom 62 370 5 0 0; -#X msg 11 208 1 3 5 7 9; -#X text 14 50 - value of first class; -#X text 14 77 - number of classes; -#X text 14 64 - value of last class; -#X text 13 35 arguments:; -#X text 14 112 - array of samples in classes; -#X text 12 97 output:; -#X text 12 133 out-of-range inputs are clipped (cfr lhisti); -#X msg 11 233 1.4 3.4 5.4 7.4 9.4; -#X msg 87 292 -10; -#X msg 11 259 0.6 2.6 4.6 6.6 8.6; -#X obj 42 396 itov; -#X text 4 399 cfr.; -#X obj 79 396 lhist; -#X obj 124 396 lhisti; -#X connect 4 0 12 0; -#X connect 5 0 4 0; -#X connect 6 0 12 0; -#X connect 7 0 12 0; -#X connect 8 0 12 0; -#X connect 12 0 3 0; -#X connect 12 0 13 0; -#X connect 13 0 14 0; -#X connect 15 0 12 0; -#X connect 23 0 12 0; -#X connect 24 0 12 0; -#X connect 25 0 12 0; diff --git a/help/itov-help.pd b/help/itov-help.pd deleted file mode 100644 index 280b20f..0000000 --- a/help/itov-help.pd +++ /dev/null @@ -1,44 +0,0 @@ -#N canvas 436 204 416 478 10; -#X text 327 442 j#|@2002; -#X text 347 423 SMLib-help; -#X msg 275 239 clear; -#X text 277 219 reinit; -#X text 11 81 - value of first class; -#X text 11 108 - number of classes; -#X text 11 95 - value of last class; -#X text 10 66 arguments:; -#X text 10 128 output:; -#X floatatom 93 445 5 0 0; -#X floatatom 45 446 5 0 0; -#X floatatom 144 445 5 0 0; -#X text 14 7 itov: intex to value; -#X text 11 36 input:; -#X text 12 52 - class index; -#X msg 134 248 absolute; -#X floatatom 94 353 5 0 0; -#X msg 16 228 4.6; -#X msg 52 228 5.4; -#X obj 37 293 hist 0 10 10; -#X obj 45 419 itov 0 10 10; -#X obj 45 324 vcog; -#X msg 86 228 5.6; -#X text 7 191 out-of-range input is clipped; -#X floatatom 69 394 5 0 0; -#X text 11 157 - center value of class i; -#X text 11 143 - lower value of class i; -#X text 11 171 - upper value of class i; -#X connect 2 0 19 0; -#X connect 15 0 19 0; -#X connect 17 0 19 0; -#X connect 17 0 15 0; -#X connect 18 0 19 0; -#X connect 18 0 15 0; -#X connect 19 0 21 0; -#X connect 20 0 10 0; -#X connect 20 1 9 0; -#X connect 20 2 11 0; -#X connect 21 0 16 0; -#X connect 21 0 20 0; -#X connect 22 0 19 0; -#X connect 22 0 15 0; -#X connect 24 0 20 0; diff --git a/help/lavg-help.pd b/help/lavg-help.pd deleted file mode 100644 index e34e589..0000000 --- a/help/lavg-help.pd +++ /dev/null @@ -1,22 +0,0 @@ -#N canvas 553 310 441 199 10; -#X text 351 171 j#|@2002; -#X obj 373 149 SMLib-help; -#X floatatom 53 75 5 0 0; -#X obj 9 58 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 -; -#X text 53 55 x(i); -#X text 6 7 lavg: leaky average; -#X obj 9 141 lavg 10; -#X floatatom 9 171 5 0 0; -#X obj 9 101 float; -#X text 5 24 argument: half-decay time (in number of activations); -#X msg 118 101 clear; -#X text 116 79 clear accumulator; -#X msg 244 106 decay 5; -#X text 243 90 set half-decay time; -#X connect 2 0 8 1; -#X connect 3 0 8 0; -#X connect 6 0 7 0; -#X connect 8 0 6 0; -#X connect 10 0 6 0; -#X connect 12 0 6 0; diff --git a/help/lhist-help.pd b/help/lhist-help.pd deleted file mode 100644 index e917047..0000000 --- a/help/lhist-help.pd +++ /dev/null @@ -1,40 +0,0 @@ -#N canvas 133 245 443 412 10; -#X text 360 376 j#|@2002; -#X text 380 357 SMLib-help; -#X obj 51 362 print; -#X obj 11 193 random 10; -#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X msg 236 193 absolute; -#X msg 236 221 relative; -#X msg 372 192 clear; -#X text 235 172 generate output; -#X text 371 173 reinit; -#X text 31 172 feed data; -#X obj 111 355 vsum; -#X floatatom 111 378 5 0 0 0 - - -; -#X msg 11 220 1 3 5 7 9; -#X text 14 50 - value of first class; -#X text 14 77 - number of classes; -#X text 14 64 - value of last class; -#X text 13 35 arguments:; -#X text 14 124 - array of samples in classes; -#X text 12 109 output:; -#X text 12 145 out-of-range inputs are clipped (cfr lhisti); -#X text 14 7 lhist: "leaky" histograms; -#X text 13 91 - half-decay time; -#X obj 51 325 lhist 0 10 10 5; -#X msg 118 194 leak; -#X text 118 172 perform leak; -#X msg 10 246 -5; -#X connect 3 0 23 0; -#X connect 4 0 3 0; -#X connect 5 0 23 0; -#X connect 6 0 23 0; -#X connect 7 0 23 0; -#X connect 11 0 12 0; -#X connect 13 0 23 0; -#X connect 23 0 2 0; -#X connect 23 0 11 0; -#X connect 24 0 23 0; -#X connect 26 0 23 0; diff --git a/help/lhisti-help.pd b/help/lhisti-help.pd deleted file mode 100644 index c770a45..0000000 --- a/help/lhisti-help.pd +++ /dev/null @@ -1,41 +0,0 @@ -#N canvas 645 245 441 405 10; -#X text 360 376 j#|@2002; -#X text 380 357 SMLib-help; -#X obj 51 362 print; -#X obj 11 193 random 10; -#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X msg 236 193 absolute; -#X msg 236 221 relative; -#X msg 372 192 clear; -#X text 235 172 generate output; -#X text 371 173 reinit; -#X text 31 172 feed data; -#X obj 111 355 vsum; -#X floatatom 111 378 5 0 0 0 - - -; -#X msg 11 220 1 3 5 7 9; -#X text 14 50 - value of first class; -#X text 14 77 - number of classes; -#X text 14 64 - value of last class; -#X text 13 35 arguments:; -#X text 14 124 - array of samples in classes; -#X text 12 109 output:; -#X text 12 145 out-of-range inputs are clipped (cfr lhisti); -#X text 13 91 - half-decay time; -#X obj 51 325 lhist 0 10 10 5; -#X msg 118 194 leak; -#X text 118 172 perform leak; -#X text 13 4 lhisti: "leaky" histograms without clipping the input -; -#X msg 11 245 -5; -#X connect 3 0 22 0; -#X connect 4 0 3 0; -#X connect 5 0 22 0; -#X connect 6 0 22 0; -#X connect 7 0 22 0; -#X connect 11 0 12 0; -#X connect 13 0 22 0; -#X connect 22 0 2 0; -#X connect 22 0 11 0; -#X connect 23 0 22 0; -#X connect 26 0 22 0; diff --git a/help/linspace-help.pd b/help/linspace-help.pd deleted file mode 100644 index 5496259..0000000 --- a/help/linspace-help.pd +++ /dev/null @@ -1,20 +0,0 @@ -#N canvas 488 507 396 195 10; -#X text 303 159 j#|@2002; -#X obj 325 139 SMLib-help; -#X obj 29 147 print linspace; -#X floatatom 136 101 5 0 0; -#X floatatom 82 80 5 0 0; -#X floatatom 29 58 5 0 0; -#X obj 11 38 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 29 36 generate; -#X text 132 80 set b; -#X text 187 101 set n; -#X text 79 56 set a and generate; -#X obj 29 124 linspace 0 1 4; -#X text 9 6 generates a vector with linear spaced floats; -#X connect 3 0 11 2; -#X connect 4 0 11 1; -#X connect 5 0 11 0; -#X connect 6 0 11 0; -#X connect 11 0 2 0; diff --git a/help/lmax-help.pd b/help/lmax-help.pd deleted file mode 100644 index 22819dd..0000000 --- a/help/lmax-help.pd +++ /dev/null @@ -1,22 +0,0 @@ -#N canvas 553 310 441 199 10; -#X text 353 169 j#|@2002; -#X obj 375 147 SMLib-help; -#X floatatom 55 73 5 0 0; -#X obj 11 56 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 55 53 x(i); -#X floatatom 11 169 5 0 0; -#X obj 11 99 float; -#X text 7 22 argument: half-decay time (in number of activations); -#X msg 119 95 clear; -#X text 118 77 clear accumulator; -#X text 8 5 lmax: leaky maximum; -#X obj 11 139 lmax 10; -#X msg 244 106 decay 5; -#X text 243 90 set half-decay time; -#X connect 2 0 6 1; -#X connect 3 0 6 0; -#X connect 6 0 11 0; -#X connect 8 0 11 0; -#X connect 11 0 5 0; -#X connect 12 0 11 0; diff --git a/help/lmin-help.pd b/help/lmin-help.pd deleted file mode 100644 index b173bd1..0000000 --- a/help/lmin-help.pd +++ /dev/null @@ -1,22 +0,0 @@ -#N canvas 553 310 444 200 10; -#X text 351 168 j#|@2002; -#X obj 373 146 SMLib-help; -#X floatatom 53 72 5 0 0; -#X obj 9 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 -; -#X text 53 52 x(i); -#X floatatom 9 168 5 0 0; -#X obj 9 98 float; -#X text 5 21 argument: half-decay time (in number of activations); -#X text 6 4 lmin: leaky minimum; -#X obj 9 138 lmin 10; -#X msg 112 92 clear; -#X text 111 73 clear accumulator; -#X msg 244 106 decay 5; -#X text 243 90 set half-decay time; -#X connect 2 0 6 1; -#X connect 3 0 6 0; -#X connect 6 0 9 0; -#X connect 9 0 5 0; -#X connect 10 0 9 0; -#X connect 12 0 9 0; diff --git a/help/lrange-help.pd b/help/lrange-help.pd deleted file mode 100644 index 270e0d5..0000000 --- a/help/lrange-help.pd +++ /dev/null @@ -1,22 +0,0 @@ -#N canvas 553 310 441 199 10; -#X text 352 168 j#|@2002; -#X obj 374 146 SMLib-help; -#X floatatom 54 72 5 0 0; -#X obj 10 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 54 52 x(i); -#X floatatom 10 168 5 0 0; -#X obj 10 98 float; -#X text 6 21 argument: half-decay time (in number of activations); -#X msg 119 98 clear; -#X text 117 76 clear accumulator; -#X text 7 4 lrange: leaky maximum minus leaky minimum; -#X obj 10 138 lrange 10; -#X msg 244 106 decay 5; -#X text 243 90 set half-decay time; -#X connect 2 0 6 1; -#X connect 3 0 6 0; -#X connect 6 0 11 0; -#X connect 8 0 11 0; -#X connect 11 0 5 0; -#X connect 12 0 11 0; diff --git a/help/prevl-help.pd b/help/prevl-help.pd deleted file mode 100644 index 29991a5..0000000 --- a/help/prevl-help.pd +++ /dev/null @@ -1,34 +0,0 @@ -#N canvas 410 463 489 262 10; -#X text 364 181 j#|@2002; -#X obj 386 159 SMLib-help; -#X floatatom -12 16 5 0 0; -#X floatatom 42 50 5 0 0; -#X floatatom 94 49 5 0 0; -#X obj -2 46 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X obj -12 -4 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text -19 167 ...; -#X text 127 79 [deltas a b c]; -#X text 94 28 b; -#X text 40 29 a; -#X text 126 125 requires b<=c; -#X text 126 109 c = buffer size; -#X text 9 -8 x(i); -#X obj -14 107 print prevl; -#X text -17 -54 prevl: generates vector with past input values (float) -; -#X text -17 128 x(i-a); -#X text -17 142 x(i-(a+1)); -#X text -17 156 x(i-(a+2)); -#X text -17 182 x(i-(b)); -#X obj -14 80 prevl 0 10 10; -#X msg 71 2 clear; -#X connect 2 0 20 0; -#X connect 2 0 5 0; -#X connect 3 0 20 1; -#X connect 4 0 20 2; -#X connect 5 0 20 0; -#X connect 6 0 2 0; -#X connect 20 0 14 0; -#X connect 21 0 20 0; diff --git a/help/threshold-help.pd b/help/threshold-help.pd deleted file mode 100644 index 07f27c6..0000000 --- a/help/threshold-help.pd +++ /dev/null @@ -1,50 +0,0 @@ -#N canvas 114 43 708 422 10; -#X text 221 309 Arguments:; -#X text 310 310 1 trigger threshold; -#X floatatom 20 235 5 0 0; -#X obj 42 363 print trigger; -#X obj 183 363 print rest; -#X text 310 341 3 rest threshold; -#X msg 172 268 1; -#X msg 208 268 0; -#X text 249 209 "set" to change the parameters; -#X text 245 263 zero or nonszero in inlet to set the state to "high" -or "low". There is no debounce period after this.; -#X text 208 12 - TRIGGER FROM FLOAT STREAM; -#X obj 124 11 threshold; -#X text 26 48 threshold monitors its input float stream and outputs -bangs when the signal exceeds a specified "trigger" value \, and also -when the input value recedes below a "rest" value. You can specify -debounce in number of floats received \, for the threshold~ to wait -after the two event types before triggering again.; -#X text 310 326 2 trigger debounce number; -#X text 309 358 4 rest debounce number; -#X obj 20 212 float; -#X obj 20 189 metro 100; -#X obj 20 148 loadbang; -#X obj 20 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 -; -#X obj 132 171 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 1200 1; -#X msg 129 208 set 50 0 10 0; -#X msg 130 231 set 50 15 10 15; -#X text 12 393 see also threshold~; -#X obj 164 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X obj 20 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X obj 20 332 threshold 70 10 30 10; -#X text 620 398 j#|@2002; -#X obj 638 376 SMLib-help; -#X connect 2 0 25 0; -#X connect 15 0 2 0; -#X connect 16 0 15 0; -#X connect 17 0 18 0; -#X connect 18 0 16 0; -#X connect 19 0 15 1; -#X connect 20 0 25 0; -#X connect 21 0 25 0; -#X connect 25 0 3 0; -#X connect 25 0 24 0; -#X connect 25 1 4 0; -#X connect 25 1 23 0; diff --git a/help/vabs-help.pd b/help/vabs-help.pd deleted file mode 100644 index 79914c7..0000000 --- a/help/vabs-help.pd +++ /dev/null @@ -1,6 +0,0 @@ -#N canvas 490 308 452 302 10; -#X obj 106 129 vabs; -#X msg 105 95 1 2 3 -4 -5 -6; -#X obj 105 165 print; -#X connect 0 0 2 0; -#X connect 1 0 0 0; diff --git a/help/vclip-help.pd b/help/vclip-help.pd deleted file mode 100644 index e182755..0000000 --- a/help/vclip-help.pd +++ /dev/null @@ -1,17 +0,0 @@ -#N canvas 588 327 324 246 10; -#X obj 11 141 vclip -1 1; -#X obj 11 196 print; -#X msg 11 30 -4 -3 -2 -1 0 1 2 3 4; -#X floatatom 73 64 5 0 0; -#X floatatom 118 103 5 0 0; -#X text 10 6 vclip clips each element in a vector; -#X text 23 166 arguments: lower bound \, upper bound; -#X text 20 52 input; -#X text 79 81 lower bound; -#X text 121 120 upper bound; -#X text 252 220 j#|@2002; -#X obj 274 200 SMLib-help; -#X connect 0 0 1 0; -#X connect 2 0 0 0; -#X connect 3 0 0 1; -#X connect 4 0 0 2; diff --git a/help/vcog-help.pd b/help/vcog-help.pd deleted file mode 100644 index 0e8d67f..0000000 --- a/help/vcog-help.pd +++ /dev/null @@ -1,21 +0,0 @@ -#N canvas 480 472 471 125 10; -#X msg 18 40 1 2 3 4; -#X floatatom 50 96 5 0 0; -#X msg 84 40 3 4 5; -#X text 387 99 j#|@2002; -#X obj 409 77 SMLib-help; -#X obj 52 69 vcog; -#X text 16 14 vcog computes the center of gravity of a list of floats -; -#X msg 134 40 0 1 0 1; -#X msg 199 40 0 0 1 1; -#X msg 263 40 8; -#X msg 144 74 1 -1; -#X text 142 94 zero sum causes no output; -#X connect 0 0 5 0; -#X connect 2 0 5 0; -#X connect 5 0 1 0; -#X connect 7 0 5 0; -#X connect 8 0 5 0; -#X connect 9 0 5 0; -#X connect 10 0 5 0; diff --git a/help/vdbtorms-help.pd b/help/vdbtorms-help.pd deleted file mode 100644 index 695fdc6..0000000 --- a/help/vdbtorms-help.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 606 355 283 118 10; -#X text 194 88 j#|@2002; -#X obj 216 68 SMLib-help; -#X msg 15 33 100 97 94; -#X text 10 6 db to rms on a vector; -#X obj 15 56 vdbtorms; -#X obj 15 80 print vdbtorms; -#X connect 2 0 4 0; -#X connect 4 0 5 0; diff --git a/help/vdelta-help.pd b/help/vdelta-help.pd deleted file mode 100644 index bda6821..0000000 --- a/help/vdelta-help.pd +++ /dev/null @@ -1,29 +0,0 @@ -#N canvas 619 449 433 228 10; -#X msg 5 30 1 1 1 1 1 1 1 1 1 1; -#X msg 5 52 1 0 1 0 1 0 1 0 1 0; -#X msg 5 74 0 1 0 1 0 1 0 1 0 1; -#X msg 5 96 0 0 0 0 0 0 0 0 0 0; -#X msg 5 118 -1 -1 0 0 -1 -1 0 0 -1 -1; -#X msg 5 140 0 0 0 0 0 1 1 1 1 1; -#X text 352 205 j#|@2002; -#X obj 373 184 SMLib-help; -#X text 7 3 vdelta: difference between consecutive vectors; -#X obj 5 193 print vdelta; -#X msg 221 31 0; -#X text 111 162 sending a vector of a different; -#X text 111 178 length resets its state; -#X obj 5 170 vdelta; -#X msg 221 57 0 0 0; -#X msg 221 79 1 2 3; -#X msg 221 101 3 2 1; -#X connect 0 0 13 0; -#X connect 1 0 13 0; -#X connect 2 0 13 0; -#X connect 3 0 13 0; -#X connect 4 0 13 0; -#X connect 5 0 13 0; -#X connect 10 0 13 0; -#X connect 13 0 9 0; -#X connect 14 0 13 0; -#X connect 15 0 13 0; -#X connect 16 0 13 0; diff --git a/help/vfmod-help.pd b/help/vfmod-help.pd deleted file mode 100644 index fb7d7a9..0000000 --- a/help/vfmod-help.pd +++ /dev/null @@ -1,17 +0,0 @@ -#N canvas 163 334 442 175 10; -#X text 364 147 j#|@2002; -#X obj 386 127 SMLib-help; -#X text 10 6 vfmod computes the modulo of each element in a vector -; -#X obj 15 127 print; -#X floatatom 66 81 5 0 0; -#X text 79 103 base; -#X text 78 119 base zero becomes one; -#X msg 15 33 0 0.5 1 1.5 2 2.5 3 3.5; -#X msg 26 58 0 -0.5 -1 -1.5 -2 -2.5 -3 -3.5; -#X obj 15 101 vfmod 2; -#X text 78 134 default argument is 1; -#X connect 4 0 9 1; -#X connect 7 0 9 0; -#X connect 8 0 9 0; -#X connect 9 0 3 0; diff --git a/help/vftom-help.pd b/help/vftom-help.pd deleted file mode 100644 index cdaf679..0000000 --- a/help/vftom-help.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 606 355 281 116 10; -#X text 194 88 j#|@2002; -#X obj 216 68 SMLib-help; -#X text 10 6 frequency to midi on a vector; -#X msg 15 33 440 446.164 880; -#X obj 15 56 vftom; -#X obj 15 80 print vftom; -#X connect 3 0 4 0; -#X connect 4 0 5 0; diff --git a/help/vlavg-help.pd b/help/vlavg-help.pd deleted file mode 100644 index 764e598..0000000 --- a/help/vlavg-help.pd +++ /dev/null @@ -1,29 +0,0 @@ -#N canvas 448 299 464 314 10; -#X obj 8 249 prepend 0; -#N canvas 0 0 450 300 graph1 0; -#X array array_vlavg 10 float 0; -#X coords 0 1 9 -1 200 140 1; -#X restore 239 102 graph; -#X msg 8 58 1 1 1 1 1 1 1 1 1 1; -#X msg 8 80 1 0 1 0 1 0 1 0 1 0; -#X msg 8 102 0 1 0 1 0 1 0 1 0 1; -#X msg 8 124 0 0 0 0 0 0 0 0 0 0; -#X obj 8 224 vlavg 6; -#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; -#X msg 8 168 0 0 0 0 0 1 1 1 1 1; -#X text 376 285 j#|@2002; -#X text 7 3 vlavg: vector leaky average; -#X text 8 22 the argument is the half-decay expressed in number of -activations; -#X obj 8 275 s array_vlavg; -#X obj 397 264 SMLib-help; -#X msg 27 201 decay 20; -#X connect 0 0 12 0; -#X connect 2 0 6 0; -#X connect 3 0 6 0; -#X connect 4 0 6 0; -#X connect 5 0 6 0; -#X connect 6 0 0 0; -#X connect 7 0 6 0; -#X connect 8 0 6 0; -#X connect 14 0 6 0; diff --git a/help/vlmax-help.pd b/help/vlmax-help.pd deleted file mode 100644 index b8a40d2..0000000 --- a/help/vlmax-help.pd +++ /dev/null @@ -1,29 +0,0 @@ -#N canvas 448 299 466 316 10; -#X obj 8 249 prepend 0; -#N canvas 0 0 450 300 graph1 0; -#X array array_vlmax 10 float 0; -#X coords 0 1 9 -1 200 140 1; -#X restore 239 102 graph; -#X msg 8 58 1 1 1 1 1 1 1 1 1 1; -#X msg 8 80 1 0 1 0 1 0 1 0 1 0; -#X msg 8 102 0 1 0 1 0 1 0 1 0 1; -#X msg 8 124 0 0 0 0 0 0 0 0 0 0; -#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; -#X msg 8 168 0 0 0 0 0 1 1 1 1 1; -#X text 376 285 j#|@2002; -#X text 8 22 the argument is the half-decay expressed in number of -activations; -#X obj 397 264 SMLib-help; -#X obj 8 224 vlmax 6; -#X obj 8 275 s array_vlmax; -#X msg 27 201 decay 20; -#X text 9 4 vlmax: vector leaky maximum; -#X connect 0 0 12 0; -#X connect 2 0 11 0; -#X connect 3 0 11 0; -#X connect 4 0 11 0; -#X connect 5 0 11 0; -#X connect 6 0 11 0; -#X connect 7 0 11 0; -#X connect 11 0 0 0; -#X connect 13 0 11 0; diff --git a/help/vlmin-help.pd b/help/vlmin-help.pd deleted file mode 100644 index 2234cef..0000000 --- a/help/vlmin-help.pd +++ /dev/null @@ -1,29 +0,0 @@ -#N canvas 448 299 466 316 10; -#X obj 8 249 prepend 0; -#N canvas 0 0 450 300 graph1 0; -#X array array_vlmin 10 float 0; -#X coords 0 1 9 -1 200 140 1; -#X restore 239 102 graph; -#X msg 8 58 1 1 1 1 1 1 1 1 1 1; -#X msg 8 80 1 0 1 0 1 0 1 0 1 0; -#X msg 8 102 0 1 0 1 0 1 0 1 0 1; -#X msg 8 124 0 0 0 0 0 0 0 0 0 0; -#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; -#X msg 8 168 0 0 0 0 0 1 1 1 1 1; -#X text 376 285 j#|@2002; -#X text 8 22 the argument is the half-decay expressed in number of -activations; -#X obj 397 264 SMLib-help; -#X obj 8 275 s array_vlmax; -#X msg 27 201 decay 20; -#X text 7 3 vlmin: vector leaky minimum; -#X obj 8 224 vlmin 6; -#X connect 0 0 11 0; -#X connect 2 0 14 0; -#X connect 3 0 14 0; -#X connect 4 0 14 0; -#X connect 5 0 14 0; -#X connect 6 0 14 0; -#X connect 7 0 14 0; -#X connect 12 0 14 0; -#X connect 14 0 0 0; diff --git a/help/vmax-help.pd b/help/vmax-help.pd deleted file mode 100644 index d615216..0000000 --- a/help/vmax-help.pd +++ /dev/null @@ -1,21 +0,0 @@ -#N canvas 480 472 473 127 10; -#X floatatom 35 104 5 0 0; -#X text 387 99 j#|@2002; -#X obj 409 77 SMLib-help; -#X msg 133 47 0; -#X msg 168 47 0 1 0 1; -#X msg 243 48 0 0 1 1; -#X text 14 3 vcog computes maximum of a list of floats; -#X obj 49 76 vmax; -#X floatatom 86 104 5 0 0; -#X msg 15 47 1 2 3 1; -#X msg 81 47 3 4 1; -#X text 13 21 and the location of the first occurance of the maximum -; -#X connect 3 0 7 0; -#X connect 4 0 7 0; -#X connect 5 0 7 0; -#X connect 7 0 0 0; -#X connect 7 1 8 0; -#X connect 9 0 7 0; -#X connect 10 0 7 0; diff --git a/help/vmin-help.pd b/help/vmin-help.pd deleted file mode 100644 index a6bc097..0000000 --- a/help/vmin-help.pd +++ /dev/null @@ -1,21 +0,0 @@ -#N canvas 480 472 473 127 10; -#X floatatom 35 104 5 0 0; -#X text 387 99 j#|@2002; -#X obj 409 77 SMLib-help; -#X msg 133 47 0; -#X msg 168 47 0 1 0 1; -#X msg 236 47 0 0 1 1; -#X floatatom 86 104 5 0 0; -#X msg 15 47 1 2 3 1; -#X msg 81 47 3 4 1; -#X text 14 3 vcog computes minimum of a list of floats; -#X text 13 21 and the location of the first occurance of the minimum -; -#X obj 49 76 vmin; -#X connect 3 0 11 0; -#X connect 4 0 11 0; -#X connect 5 0 11 0; -#X connect 7 0 11 0; -#X connect 8 0 11 0; -#X connect 11 0 0 0; -#X connect 11 1 6 0; diff --git a/help/vmtof-help.pd b/help/vmtof-help.pd deleted file mode 100644 index e0b277b..0000000 --- a/help/vmtof-help.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 606 355 279 114 10; -#X text 192 79 j#|@2002; -#X obj 214 59 SMLib-help; -#X obj 15 57 vmtof; -#X text 10 6 midi to frequency on a vector; -#X msg 15 33 69 70 81; -#X obj 15 80 print vmtof; -#X connect 2 0 5 0; -#X connect 4 0 2 0; diff --git a/help/vpow-help.pd b/help/vpow-help.pd deleted file mode 100644 index 7809a54..0000000 --- a/help/vpow-help.pd +++ /dev/null @@ -1,15 +0,0 @@ -#N canvas 163 334 444 177 10; -#X text 364 147 j#|@2002; -#X obj 386 127 SMLib-help; -#X obj 15 127 print; -#X floatatom 66 81 5 0 0 0 - - -; -#X text 78 134 default argument is 1; -#X text 10 6 vpow computes y(i)=x(i)^a; -#X text 79 103 a; -#X text 79 117 a zero becomes one; -#X obj 15 101 vpow 2; -#X msg 15 33 0.01 0.5 1 1.5 2 2.5 3 3.5 0; -#X text 27 56 if (x(i)<=0) then y(i)=-1000; -#X connect 3 0 8 1; -#X connect 8 0 2 0; -#X connect 9 0 8 0; diff --git a/help/vrms-help.pd b/help/vrms-help.pd deleted file mode 100644 index dce1a77..0000000 --- a/help/vrms-help.pd +++ /dev/null @@ -1,15 +0,0 @@ -#N canvas 381 509 392 123 10; -#X msg 17 39 1 2 3 4; -#X floatatom 50 96 5 0 0; -#X msg 84 40 3 4 5; -#X text 315 100 j#|@2002; -#X obj 337 78 SMLib-help; -#X obj 52 69 vrms; -#X text 16 14 vrms computes the root-mean-square of a vector; -#X msg 134 40 1 1 1 1; -#X msg 200 40 1 -1 1 -1; -#X connect 0 0 5 0; -#X connect 2 0 5 0; -#X connect 5 0 1 0; -#X connect 7 0 5 0; -#X connect 8 0 5 0; diff --git a/help/vrmstodb-help.pd b/help/vrmstodb-help.pd deleted file mode 100644 index 2651d44..0000000 --- a/help/vrmstodb-help.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 606 355 283 118 10; -#X text 194 88 j#|@2002; -#X obj 216 68 SMLib-help; -#X text 10 6 frequency to midi on a vector; -#X obj 15 56 vrmstodb; -#X msg 15 33 100 97 94; -#X obj 15 80 print vrmstodb; -#X connect 3 0 5 0; -#X connect 4 0 3 0; diff --git a/help/vstd-help.pd b/help/vstd-help.pd deleted file mode 100644 index 32dce16..0000000 --- a/help/vstd-help.pd +++ /dev/null @@ -1,15 +0,0 @@ -#N canvas 381 509 394 125 10; -#X msg 17 39 1 2 3 4; -#X floatatom 51 95 5 0 0; -#X msg 84 40 3 4 5; -#X text 315 100 j#|@2002; -#X obj 337 78 SMLib-help; -#X msg 134 40 1 1 1 1; -#X obj 51 70 vstd; -#X msg 200 40 1 -1 1 -1 1; -#X text 16 14 vstd computes the standard deviation of a vector; -#X connect 0 0 6 0; -#X connect 2 0 6 0; -#X connect 5 0 6 0; -#X connect 6 0 1 0; -#X connect 7 0 6 0; diff --git a/help/vsum-help.pd b/help/vsum-help.pd deleted file mode 100644 index 31ab009..0000000 --- a/help/vsum-help.pd +++ /dev/null @@ -1,13 +0,0 @@ -#N canvas 468 275 355 125 10; -#X text 16 14 vsum computes the sum of a list of floats; -#X msg 17 39 1 2 3 4; -#X obj 52 69 vsum; -#X floatatom 50 96 5 0 0; -#X msg 84 40 3 4 5; -#X text 275 102 j#|@2002; -#X obj 297 80 SMLib-help; -#X msg 136 40 0; -#X connect 1 0 2 0; -#X connect 2 0 3 0; -#X connect 4 0 2 0; -#X connect 7 0 2 0; diff --git a/help/vvconv-help.pd b/help/vvconv-help.pd deleted file mode 100644 index 3ad20a3..0000000 --- a/help/vvconv-help.pd +++ /dev/null @@ -1,35 +0,0 @@ -#N canvas 482 447 441 276 10; -#X msg 132 78 1 2 1; -#X msg 132 53 1 0 1; -#X text 26 18 vvconv: convolution of 2 vectors; -#X text 357 244 j#|@2002; -#X msg 30 43 1; -#X obj 48 130 vvconv; -#X msg 331 80 1 2 1; -#X msg 229 68 1 0 0; -#X msg 331 55 1 0 1; -#X msg 229 45 1; -#X obj 247 132 vvconv -1 2 -1; -#X msg 230 92 1 0 1 0 0 1; -#X msg 31 90 1 0 1 0 0 1; -#X text 177 178 arguments: convolution kernel; -#X obj 377 225 SMLib-help; -#X obj 48 154 print vvconv; -#X obj 247 156 print vvconv; -#X text 2 202 length of output is the sum of input lengths minus one -; -#X msg 30 66 2 0 1; -#X msg 132 103 1 0 2; -#X connect 0 0 5 1; -#X connect 1 0 5 1; -#X connect 4 0 5 0; -#X connect 5 0 15 0; -#X connect 6 0 10 1; -#X connect 7 0 10 0; -#X connect 8 0 10 1; -#X connect 9 0 10 0; -#X connect 10 0 16 0; -#X connect 11 0 10 0; -#X connect 12 0 5 0; -#X connect 18 0 5 0; -#X connect 19 0 5 1; diff --git a/help/vvminus-help.pd b/help/vvminus-help.pd deleted file mode 100644 index 48c626b..0000000 --- a/help/vvminus-help.pd +++ /dev/null @@ -1,23 +0,0 @@ -#N canvas 561 440 326 219 10; -#X msg 25 90 1 2 3; -#X msg 82 94 4 5 6; -#X msg 168 95 1 2 3; -#X msg 228 95 4; -#X msg 25 66 1; -#X msg 168 71 1; -#X text 248 191 j#|@2002; -#X text 18 10 vv- substracts two lists of floats; -#X text 18 26 or a float from a list of floats; -#X obj 49 124 vv-; -#X obj 189 125 vv- 0; -#X obj 268 170 SMLib-help; -#X obj 49 148 print vv-; -#X obj 189 149 print vv-; -#X connect 0 0 9 0; -#X connect 1 0 9 1; -#X connect 2 0 10 0; -#X connect 3 0 10 1; -#X connect 4 0 9 0; -#X connect 5 0 10 0; -#X connect 9 0 12 0; -#X connect 10 0 13 0; diff --git a/help/vvplus-help.pd b/help/vvplus-help.pd deleted file mode 100644 index 04c3065..0000000 --- a/help/vvplus-help.pd +++ /dev/null @@ -1,25 +0,0 @@ -#N canvas 561 440 313 218 10; -#X obj 40 115 vv+; -#X msg 16 81 1 2 3; -#X msg 73 85 4 5 6; -#X msg 159 86 1 2 3; -#X msg 219 86 4; -#X obj 180 116 vv+ 0; -#X msg 16 57 1; -#X msg 159 62 1; -#X text 18 10 vv+ adds two lists of floats; -#X text 17 25 or a float to a list of floats; -#X msg 73 60 3 2 1; -#X obj 252 159 SMLib-help; -#X text 230 184 j#|@2002; -#X obj 40 139 print vv+; -#X obj 180 140 print vv+; -#X connect 0 0 13 0; -#X connect 1 0 0 0; -#X connect 2 0 0 1; -#X connect 3 0 5 0; -#X connect 4 0 5 1; -#X connect 5 0 14 0; -#X connect 6 0 0 0; -#X connect 7 0 5 0; -#X connect 10 0 0 1; diff --git a/hip-help.pd b/hip-help.pd new file mode 100644 index 0000000..49587c5 --- /dev/null +++ b/hip-help.pd @@ -0,0 +1,32 @@ +#N canvas 114 43 430 286 10; +#X floatatom 12 141 5 0 0; +#X obj 12 118 float; +#X obj 12 95 metro 100; +#X obj 12 54 loadbang; +#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 12700 1; +#X text 349 255 j#|@2002; +#X obj 367 233 SMLib-help; +#X floatatom 138 133 0 0 0; +#X msg 106 110 clear; +#X text 156 109 <-- reinitialize internal state; +#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 6350 1; +#X floatatom 17 237 5 0 0; +#X text 262 76 <-- swing!; +#X text 13 7 hip: highpass filter on float stream; +#X text 11 25 the non-audio version of hip~; +#X obj 19 182 hip 0.05; +#X text 170 134 <-- cutoff frequency; +#X connect 1 0 0 0; +#X connect 1 0 16 0; +#X connect 2 0 1 0; +#X connect 3 0 4 0; +#X connect 4 0 2 0; +#X connect 5 0 1 1; +#X connect 8 0 16 1; +#X connect 9 0 16 0; +#X connect 11 0 12 0; +#X connect 16 0 11 0; diff --git a/hip.c b/hip.c new file mode 100644 index 0000000..b1425c1 --- /dev/null +++ b/hip.c @@ -0,0 +1,77 @@ +#include "defines.h" + +/*--------------- hip ---------------*/ + +typedef struct hipctl +{ + float c_x; + float c_coef; +} t_hipctl; + +typedef struct hip +{ + t_object x_obj; + float x_sr; + float x_hz; + t_hipctl x_cspace; + t_hipctl *x_ctl; + float x_f; +} t_hip; + +t_class *hip_class; + +static void hip_ft1(t_hip *x, t_floatarg f); + +static void *hip_new(t_floatarg f) +{ + t_hip *x = (t_hip *)pd_new(hip_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + outlet_new(&x->x_obj, gensym("float")); + x->x_ctl = &x->x_cspace; + x->x_cspace.c_x = 0; + hip_ft1(x, f); + x->x_f = 0; + return (x); +} + +static void hip_ft1(t_hip *x, t_floatarg f) +{ + if (f < 0.001) f = 10; + x->x_hz = f; + x->x_ctl->c_coef = 1 - f * (2 * 3.14159f); + if (x->x_ctl->c_coef < 0) x->x_ctl->c_coef = 0; +} + +static void hip_perform(t_hip *x, t_float in) +{ + t_hipctl *c = x->x_ctl; + float last = c->c_x; + float coef = c->c_coef; + float out; + + float new = in + coef * last; + out = new - last; + last = new; + + /* NAN protect */ + if (!((last <= 0) || (last >= 0))) + last = 0; + c->c_x = last; + + outlet_float(x->x_obj.ob_outlet, out); +} + +static void hip_clear(t_hip *x, t_floatarg q) +{ + x->x_cspace.c_x = 0; +} + +void hip_setup(void) +{ + hip_class = class_new(gensym("hip"), (t_newmethod)hip_new, 0, + sizeof(t_hip), 0, A_DEFFLOAT, 0); + class_addfloat(hip_class, (t_method)hip_perform); + class_addmethod(hip_class, (t_method)hip_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(hip_class, (t_method)hip_clear, gensym("clear"), 0); +} \ No newline at end of file diff --git a/hist-help.pd b/hist-help.pd new file mode 100644 index 0000000..fd3984a --- /dev/null +++ b/hist-help.pd @@ -0,0 +1,44 @@ +#N canvas 678 207 414 422 10; +#X text 331 381 j#|@2002; +#X text 351 362 SMLib-help; +#X text 14 7 hist: histograms; +#X obj 2 354 print; +#X obj 11 181 random 10; +#X obj 11 162 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 129 177 absolute; +#X msg 129 205 relative; +#X msg 276 177 clear; +#X text 128 156 generate output; +#X text 275 159 reinit; +#X text 31 160 feed data; +#X obj 2 317 hist 0 10 10; +#X obj 62 347 vsum; +#X floatatom 62 370 5 0 0; +#X msg 11 208 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 112 - array of samples in classes; +#X text 12 97 output:; +#X text 12 133 out-of-range inputs are clipped (cfr lhisti); +#X msg 11 233 1.4 3.4 5.4 7.4 9.4; +#X msg 87 292 -10; +#X msg 11 259 0.6 2.6 4.6 6.6 8.6; +#X obj 42 396 itov; +#X text 4 399 cfr.; +#X obj 79 396 lhist; +#X obj 124 396 lhisti; +#X connect 4 0 12 0; +#X connect 5 0 4 0; +#X connect 6 0 12 0; +#X connect 7 0 12 0; +#X connect 8 0 12 0; +#X connect 12 0 3 0; +#X connect 12 0 13 0; +#X connect 13 0 14 0; +#X connect 15 0 12 0; +#X connect 23 0 12 0; +#X connect 24 0 12 0; +#X connect 25 0 12 0; diff --git a/hist.c b/hist.c new file mode 100644 index 0000000..ba492f2 --- /dev/null +++ b/hist.c @@ -0,0 +1,155 @@ +#include "defines.h" + +/*--------------- hist ---------------*/ + + +static t_class *hist_class; + +typedef struct _hist +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + int m_nbins; + int m_n_observations; + float *m_hist; +} t_hist; + + +static void hist_perform_float(t_hist *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_hist[j]++; + x->m_n_observations++; +} + +static void hist_perform_list(t_hist *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_hist[j]++; + } + x->m_n_observations+=argc; +} + +static void hist_bang(t_hist *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + + i=x->m_nbins; + f=x->m_hist; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void hist_relative(t_hist *x) +{ + int i,n; + float *f; + float invn; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + + invn=1.0f/(1e-10f+x->m_n_observations); + + i=n; + f=x->m_hist; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void hist_clear(t_hist *x) +{ + int i; + float *f; + f=x->m_hist; + for (i=0;im_nbins;i++) + *f++=0.0f; + x->m_n_observations=0; +} + + +static void hist_set(t_hist *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("hist: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("hist: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + + freebytes(x->m_hist, x->m_nbins); + + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_hist = (float*)getbytes(sizeof(float)*x->m_nbins); + + hist_clear(x); +} + +static void *hist_new(t_float lo, t_float hi, t_float nbins) +{ + t_hist *x=(t_hist *)pd_new(hist_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_hist=0; + x->m_nbins=0; + hist_set(x, lo, hi, nbins); + return (void *)x; +} + +static void hist_free(t_hist *x) +{ + freebytes(x->m_hist, x->m_nbins); +} + +void hist_setup(void) +{ + hist_class = class_new(gensym("hist"), + (t_newmethod)hist_new, (t_method)hist_free, + sizeof(t_hist), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(hist_class, (t_method)hist_clear, gensym("clear"),0); + class_addmethod(hist_class, (t_method)hist_bang, gensym("absolute"),0); + class_addmethod(hist_class, (t_method)hist_relative, gensym("relative"),0); + + class_addmethod(hist_class, (t_method)hist_set, gensym("set"),A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addlist(hist_class, (t_method)hist_perform_list); + class_addfloat(hist_class, (t_method)hist_perform_float); + class_addbang(hist_class, (t_method)hist_bang); +} + diff --git a/itov-help.pd b/itov-help.pd new file mode 100644 index 0000000..280b20f --- /dev/null +++ b/itov-help.pd @@ -0,0 +1,44 @@ +#N canvas 436 204 416 478 10; +#X text 327 442 j#|@2002; +#X text 347 423 SMLib-help; +#X msg 275 239 clear; +#X text 277 219 reinit; +#X text 11 81 - value of first class; +#X text 11 108 - number of classes; +#X text 11 95 - value of last class; +#X text 10 66 arguments:; +#X text 10 128 output:; +#X floatatom 93 445 5 0 0; +#X floatatom 45 446 5 0 0; +#X floatatom 144 445 5 0 0; +#X text 14 7 itov: intex to value; +#X text 11 36 input:; +#X text 12 52 - class index; +#X msg 134 248 absolute; +#X floatatom 94 353 5 0 0; +#X msg 16 228 4.6; +#X msg 52 228 5.4; +#X obj 37 293 hist 0 10 10; +#X obj 45 419 itov 0 10 10; +#X obj 45 324 vcog; +#X msg 86 228 5.6; +#X text 7 191 out-of-range input is clipped; +#X floatatom 69 394 5 0 0; +#X text 11 157 - center value of class i; +#X text 11 143 - lower value of class i; +#X text 11 171 - upper value of class i; +#X connect 2 0 19 0; +#X connect 15 0 19 0; +#X connect 17 0 19 0; +#X connect 17 0 15 0; +#X connect 18 0 19 0; +#X connect 18 0 15 0; +#X connect 19 0 21 0; +#X connect 20 0 10 0; +#X connect 20 1 9 0; +#X connect 20 2 11 0; +#X connect 21 0 16 0; +#X connect 21 0 20 0; +#X connect 22 0 19 0; +#X connect 22 0 15 0; +#X connect 24 0 20 0; diff --git a/itov.c b/itov.c new file mode 100644 index 0000000..fa68a90 --- /dev/null +++ b/itov.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- itov ---------------*/ + + +static t_class *itov_class; + +typedef struct _itov +{ + t_object x_obj; + t_outlet *f_out1; + t_outlet *f_out2; + t_outlet *f_out3; + float m_lo; + float m_hi; + float m_scale; + int m_nbins; +} t_itov; + + +static void itov_perform_float(t_itov *x, t_float j) +{ + float i; + j-=1.0f; + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + +// j=(int)((f-x->m_lo)*x->m_scale); + i=(j/x->m_scale)-x->m_lo; + + outlet_float(x->f_out2, i); + +} + +static void itov_perform_list(t_itov *x, t_symbol *s, int argc, t_atom *argv) +{ + + +} + +static void itov_set(t_itov *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("itov: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("itov: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); +} + +static void *itov_new(t_float lo, t_float hi, t_float nbins) +{ + t_itov *x=(t_itov *)pd_new(itov_class); + x->f_out1=outlet_new(&x->x_obj, gensym("float")); + x->f_out2=outlet_new(&x->x_obj, gensym("float")); + x->f_out3=outlet_new(&x->x_obj, gensym("float")); + + x->m_nbins=0; + itov_set(x, lo, hi, nbins); + return (void *)x; +} + +static void itov_free(t_itov *x) +{ +} + +void itov_setup(void) +{ + itov_class = class_new(gensym("itov"), + (t_newmethod)itov_new, (t_method)itov_free, + sizeof(t_itov), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + +// class_addlist(itov_class, (t_method)itov_perform_list); + class_addfloat(itov_class, (t_method)itov_perform_float); +} + diff --git a/lavg-help.pd b/lavg-help.pd new file mode 100644 index 0000000..e34e589 --- /dev/null +++ b/lavg-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 10; +#X text 351 171 j#|@2002; +#X obj 373 149 SMLib-help; +#X floatatom 53 75 5 0 0; +#X obj 9 58 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 +; +#X text 53 55 x(i); +#X text 6 7 lavg: leaky average; +#X obj 9 141 lavg 10; +#X floatatom 9 171 5 0 0; +#X obj 9 101 float; +#X text 5 24 argument: half-decay time (in number of activations); +#X msg 118 101 clear; +#X text 116 79 clear accumulator; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 8 1; +#X connect 3 0 8 0; +#X connect 6 0 7 0; +#X connect 8 0 6 0; +#X connect 10 0 6 0; +#X connect 12 0 6 0; diff --git a/lavg.c b/lavg.c new file mode 100644 index 0000000..fce0015 --- /dev/null +++ b/lavg.c @@ -0,0 +1,55 @@ +#include "defines.h" + +/*--------------- lavg ---------------*/ + +static t_class *lavg_class; + +typedef struct _lavg +{ + t_object x_obj; + float m_avg; + float m_c_leak; + float m_leak; +} t_lavg; + + +static void lavg_perform(t_lavg *x, t_float in) +{ + x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_avg); +} + +static void lavg_clear(t_lavg *x) +{ + x->m_avg=0.0f; +} + +static void lavg_setHalfDecay(t_lavg *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *lavg_new( t_float halfDecayTime) +{ + t_lavg *x=(t_lavg *)pd_new(lavg_class); + outlet_new(&x->x_obj, gensym("float")); + + lavg_setHalfDecay(x, halfDecayTime); + return (void *)x; +} + +void lavg_setup(void) +{ + lavg_class = class_new(gensym("lavg"), + (t_newmethod)lavg_new, 0, + sizeof(t_lavg), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lavg_class, (t_method)lavg_perform); + class_addmethod(lavg_class, (t_method)lavg_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addmethod(lavg_class, (t_method)lavg_clear, + gensym("clear"), 0); +} + diff --git a/lhist-help.pd b/lhist-help.pd new file mode 100644 index 0000000..e917047 --- /dev/null +++ b/lhist-help.pd @@ -0,0 +1,40 @@ +#N canvas 133 245 443 412 10; +#X text 360 376 j#|@2002; +#X text 380 357 SMLib-help; +#X obj 51 362 print; +#X obj 11 193 random 10; +#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 236 193 absolute; +#X msg 236 221 relative; +#X msg 372 192 clear; +#X text 235 172 generate output; +#X text 371 173 reinit; +#X text 31 172 feed data; +#X obj 111 355 vsum; +#X floatatom 111 378 5 0 0 0 - - -; +#X msg 11 220 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 124 - array of samples in classes; +#X text 12 109 output:; +#X text 12 145 out-of-range inputs are clipped (cfr lhisti); +#X text 14 7 lhist: "leaky" histograms; +#X text 13 91 - half-decay time; +#X obj 51 325 lhist 0 10 10 5; +#X msg 118 194 leak; +#X text 118 172 perform leak; +#X msg 10 246 -5; +#X connect 3 0 23 0; +#X connect 4 0 3 0; +#X connect 5 0 23 0; +#X connect 6 0 23 0; +#X connect 7 0 23 0; +#X connect 11 0 12 0; +#X connect 13 0 23 0; +#X connect 23 0 2 0; +#X connect 23 0 11 0; +#X connect 24 0 23 0; +#X connect 26 0 23 0; diff --git a/lhist.c b/lhist.c new file mode 100644 index 0000000..ea20edc --- /dev/null +++ b/lhist.c @@ -0,0 +1,174 @@ +#include "defines.h" + +/*--------------- lhist ---------------*/ + +static t_class *lhist_class; + +typedef struct _lhist +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + float m_c_leak; + float m_leak; + int m_nbins; +// int m_n_observations; + float *m_lhist; +} t_lhist; + +static void lhist_setHalfDecay(t_lhist *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lhist_perform_float(t_lhist *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_lhist[j]++; +// x->m_n_observations++; +} + +static void lhist_perform_list(t_lhist *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_lhist[j]++; + } +// x->m_n_observations+=argc; +} + +static void lhist_leak(t_lhist *x) +{ + int i; + float *f; + float sc; + f=x->m_lhist; + sc=x->m_c_leak; + i=x->m_nbins; + while(i--) + *f++*=sc; +} + +static void lhist_bang(t_lhist *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=n; + f=x->m_lhist; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhist_relative(t_lhist *x) +{ + int i,n; + float *f; + float invn,sum; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=x->m_nbins; + f=x->m_lhist; + sum=0.0f; + while(i--) sum+=*f++; + invn=1.0f/(1e-10f+sum); + + i=x->m_nbins; + f=x->m_lhist; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhist_clear(t_lhist *x) +{ + int i; + float *f; + f=x->m_lhist; + for (i=0;im_nbins;i++) + *f++=0.0f; +// x->m_n_observations=0; +} + +static void lhist_set(t_lhist *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("lhist: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("lhist: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + freebytes(x->m_lhist, x->m_nbins); + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_lhist = (float*)getbytes(sizeof(float)*x->m_nbins); + + lhist_clear(x); +} + +static void *lhist_new(t_float lo, t_float hi, t_float nbins, t_float decay) +{ + t_lhist *x=(t_lhist *)pd_new(lhist_class); + outlet_new(&x->x_obj, gensym("list")); + lhist_setHalfDecay(x,decay); + x->m_nbins=0; + x->m_lhist=0; + lhist_set(x, lo, hi, nbins); + return (void *)x; +} + +static void lhist_free(t_lhist *x) +{ + freebytes(x->m_lhist, x->m_nbins); +} + +void lhist_setup(void) +{ + lhist_class = class_new(gensym("lhist"), + (t_newmethod)lhist_new, (t_method)lhist_free, + sizeof(t_lhist), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); + + class_addmethod(lhist_class, (t_method)lhist_clear, gensym("clear"),0); + class_addmethod(lhist_class, (t_method)lhist_bang, gensym("absolute"),0); + class_addmethod(lhist_class, (t_method)lhist_relative, gensym("relative"),0); + class_addmethod(lhist_class, (t_method)lhist_leak, gensym("leak"),0); + class_addmethod(lhist_class, (t_method)lhist_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + + class_addlist(lhist_class, (t_method)lhist_perform_list); + class_addfloat(lhist_class, (t_method)lhist_perform_float); + class_addbang(lhist_class, (t_method)lhist_bang); +} + diff --git a/lhisti-help.pd b/lhisti-help.pd new file mode 100644 index 0000000..c770a45 --- /dev/null +++ b/lhisti-help.pd @@ -0,0 +1,41 @@ +#N canvas 645 245 441 405 10; +#X text 360 376 j#|@2002; +#X text 380 357 SMLib-help; +#X obj 51 362 print; +#X obj 11 193 random 10; +#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 236 193 absolute; +#X msg 236 221 relative; +#X msg 372 192 clear; +#X text 235 172 generate output; +#X text 371 173 reinit; +#X text 31 172 feed data; +#X obj 111 355 vsum; +#X floatatom 111 378 5 0 0 0 - - -; +#X msg 11 220 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 124 - array of samples in classes; +#X text 12 109 output:; +#X text 12 145 out-of-range inputs are clipped (cfr lhisti); +#X text 13 91 - half-decay time; +#X obj 51 325 lhist 0 10 10 5; +#X msg 118 194 leak; +#X text 118 172 perform leak; +#X text 13 4 lhisti: "leaky" histograms without clipping the input +; +#X msg 11 245 -5; +#X connect 3 0 22 0; +#X connect 4 0 3 0; +#X connect 5 0 22 0; +#X connect 6 0 22 0; +#X connect 7 0 22 0; +#X connect 11 0 12 0; +#X connect 13 0 22 0; +#X connect 22 0 2 0; +#X connect 22 0 11 0; +#X connect 23 0 22 0; +#X connect 26 0 22 0; diff --git a/lhisti.c b/lhisti.c new file mode 100644 index 0000000..826cce4 --- /dev/null +++ b/lhisti.c @@ -0,0 +1,174 @@ +#include "defines.h" + +/*--------------- lhisti ---------------*/ +// ignores samples outside bins + +static t_class *lhisti_class; + +typedef struct _lhisti +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + float m_c_leak; + float m_leak; + int m_nbins; +// int m_n_observations; + float *m_lhisti; +} t_lhisti; + +static void lhisti_setHalfDecay(t_lhisti *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lhisti_perform_float(t_lhisti *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + if ((j>=0)&&(jm_nbins)) + x->m_lhisti[j]++; +} + +static void lhisti_perform_list(t_lhisti *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + if ((j>=0)&&(jm_nbins)) + x->m_lhisti[j]++; + } +// x->m_n_observations+=argc; +} + +static void lhisti_leak(t_lhisti *x) +{ + int i; + float *f; + float sc; + f=x->m_lhisti; + sc=x->m_c_leak; + i=x->m_nbins; + while(i--) + *f++*=sc; +} + +static void lhisti_bang(t_lhisti *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=n; + f=x->m_lhisti; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhisti_relative(t_lhisti *x) +{ + int i,n; + float *f; + float invn,sum; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=x->m_nbins; + f=x->m_lhisti; + sum=0.0f; + while(i--) sum+=*f++; + invn=1.0f/(1e-10f+sum); + + i=x->m_nbins; + f=x->m_lhisti; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhisti_clear(t_lhisti *x) +{ + int i; + float *f; + f=x->m_lhisti; + for (i=0;im_nbins;i++) + *f++=0.0f; +// x->m_n_observations=0; +} + +static void lhisti_set(t_lhisti *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("lhisti: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("lhisti: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + freebytes(x->m_lhisti, x->m_nbins); + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_lhisti = (float*)getbytes(sizeof(float)*x->m_nbins); + + lhisti_clear(x); +} + +static void *lhisti_new(t_float lo, t_float hi, t_float nbins, t_float decay) +{ + t_lhisti *x=(t_lhisti *)pd_new(lhisti_class); + outlet_new(&x->x_obj, gensym("list")); + lhisti_setHalfDecay(x,decay); + x->m_nbins=0; + x->m_lhisti=0; + lhisti_set(x, lo, hi, nbins); + return (void *)x; +} + +static void lhisti_free(t_lhisti *x) +{ + freebytes(x->m_lhisti, x->m_nbins); +} + +void lhisti_setup(void) +{ + lhisti_class = class_new(gensym("lhisti"), + (t_newmethod)lhisti_new, (t_method)lhisti_free, + sizeof(t_lhisti), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); + + class_addmethod(lhisti_class, (t_method)lhisti_clear, gensym("clear"),0); + class_addmethod(lhisti_class, (t_method)lhisti_bang, gensym("absolute"),0); + class_addmethod(lhisti_class, (t_method)lhisti_relative, gensym("relative"),0); + class_addmethod(lhisti_class, (t_method)lhisti_leak, gensym("leak"),0); + class_addmethod(lhisti_class, (t_method)lhisti_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + + class_addlist(lhisti_class, (t_method)lhisti_perform_list); + class_addfloat(lhisti_class, (t_method)lhisti_perform_float); + class_addbang(lhisti_class, (t_method)lhisti_bang); +} + diff --git a/linspace-help.pd b/linspace-help.pd new file mode 100644 index 0000000..5496259 --- /dev/null +++ b/linspace-help.pd @@ -0,0 +1,20 @@ +#N canvas 488 507 396 195 10; +#X text 303 159 j#|@2002; +#X obj 325 139 SMLib-help; +#X obj 29 147 print linspace; +#X floatatom 136 101 5 0 0; +#X floatatom 82 80 5 0 0; +#X floatatom 29 58 5 0 0; +#X obj 11 38 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 29 36 generate; +#X text 132 80 set b; +#X text 187 101 set n; +#X text 79 56 set a and generate; +#X obj 29 124 linspace 0 1 4; +#X text 9 6 generates a vector with linear spaced floats; +#X connect 3 0 11 2; +#X connect 4 0 11 1; +#X connect 5 0 11 0; +#X connect 6 0 11 0; +#X connect 11 0 2 0; diff --git a/linspace.c b/linspace.c new file mode 100644 index 0000000..c3af9c2 --- /dev/null +++ b/linspace.c @@ -0,0 +1,74 @@ +#include "defines.h" + +/*--------------- linspace ----------------*/ +/* clips a vector */ + + +static t_class *linspace_class; + +typedef struct _linspace +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_n; +} t_linspace; + + +static void linspace_bang(t_linspace *x) +{ + int n; + n=(int)x->m_n; + if ((n<256)&&(n>1)) + { + int i; + float lo,step; + t_atom *ap,*app; + + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + lo=x->m_lo; + step=(x->m_hi-lo)/(n-1); + for (i = 0; i < n; i++) + { + + SETFLOAT(app, lo); + app++; + lo+=step; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); + } +} + +static void linspace_float(t_linspace *x, t_float lo) +{ + x->m_lo=lo; + linspace_bang(x); +} + +static void *linspace_new(t_float lo, t_float hi, t_float n) +{ + t_linspace *x=(t_linspace *)pd_new(linspace_class); + + floatinlet_new(&x->x_obj, &x->m_hi); + floatinlet_new(&x->x_obj, &x->m_n); + + outlet_new(&x->x_obj, gensym("list")); + x->m_lo=lo; + x->m_hi=hi; + x->m_n=n; + return (void *)x; +} + +void linspace_setup(void) +{ + linspace_class = class_new(gensym("linspace"), + (t_newmethod)linspace_new, 0, + sizeof(t_linspace), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); + class_addfloat(linspace_class, (t_method)linspace_float); + class_addbang(linspace_class, (t_method)linspace_bang); +} + diff --git a/lmax-help.pd b/lmax-help.pd new file mode 100644 index 0000000..22819dd --- /dev/null +++ b/lmax-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 10; +#X text 353 169 j#|@2002; +#X obj 375 147 SMLib-help; +#X floatatom 55 73 5 0 0; +#X obj 11 56 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 55 53 x(i); +#X floatatom 11 169 5 0 0; +#X obj 11 99 float; +#X text 7 22 argument: half-decay time (in number of activations); +#X msg 119 95 clear; +#X text 118 77 clear accumulator; +#X text 8 5 lmax: leaky maximum; +#X obj 11 139 lmax 10; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 5 0; +#X connect 12 0 11 0; diff --git a/lmax.c b/lmax.c new file mode 100644 index 0000000..911304f --- /dev/null +++ b/lmax.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- lmax ---------------*/ + +static t_class *lmax_class; + +typedef struct _lmax +{ + t_object x_obj; + float m_max; + float m_leak; + float m_c_leak; +} t_lmax; + + +static void lmax_perform(t_lmax *x, t_float in) +{ + x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_max); +} + +static void lmax_setHalfDecay(t_lmax *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lmax_clear(t_lmax *x) +{ + x->m_max= - MAXFLOAT; +} + +static void *lmax_new( t_float halfDecayTime) +{ + t_lmax *x=(t_lmax *)pd_new(lmax_class); + outlet_new(&x->x_obj, gensym("float")); + + lmax_setHalfDecay(x, halfDecayTime); + lmax_clear(x); + return (void *)x; +} + + +void lmax_setup(void) +{ + lmax_class = class_new(gensym("lmax"), + (t_newmethod)lmax_new, 0, + sizeof(t_lmax), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lmax_class, (t_method)lmax_perform); + class_addmethod(lmax_class, (t_method)lmax_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lmax_class, (t_method)lmax_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/lmin-help.pd b/lmin-help.pd new file mode 100644 index 0000000..b173bd1 --- /dev/null +++ b/lmin-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 444 200 10; +#X text 351 168 j#|@2002; +#X obj 373 146 SMLib-help; +#X floatatom 53 72 5 0 0; +#X obj 9 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 +; +#X text 53 52 x(i); +#X floatatom 9 168 5 0 0; +#X obj 9 98 float; +#X text 5 21 argument: half-decay time (in number of activations); +#X text 6 4 lmin: leaky minimum; +#X obj 9 138 lmin 10; +#X msg 112 92 clear; +#X text 111 73 clear accumulator; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 9 0; +#X connect 9 0 5 0; +#X connect 10 0 9 0; +#X connect 12 0 9 0; diff --git a/lmin.c b/lmin.c new file mode 100644 index 0000000..51b333a --- /dev/null +++ b/lmin.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- lmin ---------------*/ + +static t_class *lmin_class; + +typedef struct _lmin +{ + t_object x_obj; + float m_min; + float m_leak; + float m_c_leak; +} t_lmin; + + +static void lmin_perform(t_lmin *x, t_float in) +{ + x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_min); +} + +static void lmin_setHalfDecay(t_lmin *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lmin_clear(t_lmin *x) +{ + x->m_min= MAXFLOAT; +} + +static void *lmin_new( t_float halfDecayTime) +{ + t_lmin *x=(t_lmin *)pd_new(lmin_class); + outlet_new(&x->x_obj, gensym("float")); + + lmin_setHalfDecay(x, halfDecayTime); + lmin_clear(x); + return (void *)x; +} + + +void lmin_setup(void) +{ + lmin_class = class_new(gensym("lmin"), + (t_newmethod)lmin_new, 0, + sizeof(t_lmin), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lmin_class, (t_method)lmin_perform); + class_addmethod(lmin_class, (t_method)lmin_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lmin_class, (t_method)lmin_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/lrange-help.pd b/lrange-help.pd new file mode 100644 index 0000000..270e0d5 --- /dev/null +++ b/lrange-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 10; +#X text 352 168 j#|@2002; +#X obj 374 146 SMLib-help; +#X floatatom 54 72 5 0 0; +#X obj 10 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 54 52 x(i); +#X floatatom 10 168 5 0 0; +#X obj 10 98 float; +#X text 6 21 argument: half-decay time (in number of activations); +#X msg 119 98 clear; +#X text 117 76 clear accumulator; +#X text 7 4 lrange: leaky maximum minus leaky minimum; +#X obj 10 138 lrange 10; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 5 0; +#X connect 12 0 11 0; diff --git a/lrange.c b/lrange.c new file mode 100644 index 0000000..8f5b296 --- /dev/null +++ b/lrange.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- lrange ---------------*/ + +static t_class *lrange_class; + +typedef struct _lrange +{ + t_object x_obj; + float m_min; + float m_max; + float m_c_leak; + float m_leak; +} t_lrange; + + +static void lrange_perform(t_lrange *x, t_float in) +{ + x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; + x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_max-x->m_min); +} + +static void lrange_setHalfDecay(t_lrange *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lrange_clear(t_lrange *x) +{ + x->m_max = - MAXFLOAT; + x->m_min = MAXFLOAT; +} + +static void *lrange_new( t_float halfDecayTime) +{ + t_lrange *x=(t_lrange *)pd_new(lrange_class); + outlet_new(&x->x_obj, gensym("float")); + + lrange_setHalfDecay(x, halfDecayTime); + lrange_clear(x); + return (void *)x; +} + + +void lrange_setup(void) +{ + lrange_class = class_new(gensym("lrange"), + (t_newmethod)lrange_new, 0, + sizeof(t_lrange), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lrange_class, (t_method)lrange_perform); + class_addmethod(lrange_class, (t_method)lrange_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lrange_class, (t_method)lrange_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/lstd-help.pd b/lstd-help.pd new file mode 100644 index 0000000..8178315 --- /dev/null +++ b/lstd-help.pd @@ -0,0 +1,9 @@ +#N canvas 559 356 441 199 10; +#X text 353 169 j#|@2002; +#X obj 375 147 SMLib-help; +#X floatatom 74 115 5 0 0 0 - - -; +#X obj 74 85 lstd; +#X obj 76 47 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 0 1; +#X connect 3 0 2 0; +#X connect 4 0 3 0; diff --git a/lstd.c b/lstd.c new file mode 100644 index 0000000..1873bda --- /dev/null +++ b/lstd.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- lstd ---------------*/ + +static t_class *lstd_class; + +typedef struct _lstd +{ + t_object x_obj; + float m_avg; + float m_sum_squares; + float m_std; + float m_c_leak; + float m_leak; +} t_lstd; + + +static void lstd_perform(t_lstd *x, t_float in) +{ + float tmp=x->m_avg-in; + x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; + x->m_sum_squares=x->m_sum_squares * x->m_c_leak + x->m_leak*tmp*tmp; + x->m_std=(float)sqrtf(x->m_sum_squares); + outlet_float(x->x_obj.ob_outlet, x->m_std); +} + +static void lstd_setHalfDecay(t_lstd *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lstd_clear(t_lstd *x) +{ + x->m_sum_squares=0.0f; + x->m_avg=0.0f; +} + +static void *lstd_new( t_float halfDecayTime) +{ + t_lstd *x=(t_lstd *)pd_new(lstd_class); + outlet_new(&x->x_obj, gensym("float")); + + lstd_setHalfDecay(x, halfDecayTime); + return (void *)x; +} + + +void lstd_setup(void) +{ + lstd_class = class_new(gensym("lstd"), + (t_newmethod)lstd_new, 0, + sizeof(t_lstd), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lstd_class, (t_method)lstd_perform); + class_addmethod(lstd_class, (t_method)lstd_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/prevl-help.pd b/prevl-help.pd new file mode 100644 index 0000000..29991a5 --- /dev/null +++ b/prevl-help.pd @@ -0,0 +1,34 @@ +#N canvas 410 463 489 262 10; +#X text 364 181 j#|@2002; +#X obj 386 159 SMLib-help; +#X floatatom -12 16 5 0 0; +#X floatatom 42 50 5 0 0; +#X floatatom 94 49 5 0 0; +#X obj -2 46 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj -12 -4 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text -19 167 ...; +#X text 127 79 [deltas a b c]; +#X text 94 28 b; +#X text 40 29 a; +#X text 126 125 requires b<=c; +#X text 126 109 c = buffer size; +#X text 9 -8 x(i); +#X obj -14 107 print prevl; +#X text -17 -54 prevl: generates vector with past input values (float) +; +#X text -17 128 x(i-a); +#X text -17 142 x(i-(a+1)); +#X text -17 156 x(i-(a+2)); +#X text -17 182 x(i-(b)); +#X obj -14 80 prevl 0 10 10; +#X msg 71 2 clear; +#X connect 2 0 20 0; +#X connect 2 0 5 0; +#X connect 3 0 20 1; +#X connect 4 0 20 2; +#X connect 5 0 20 0; +#X connect 6 0 2 0; +#X connect 20 0 14 0; +#X connect 21 0 20 0; diff --git a/prevl.c b/prevl.c new file mode 100644 index 0000000..2ba39ce --- /dev/null +++ b/prevl.c @@ -0,0 +1,161 @@ +#include "defines.h" + +/*--------------- prevl ---------------*/ + +static t_class *prevl_class; + +typedef struct _prevl +{ + t_object x_obj; + float m_lo; + float m_hi; + int m_buffer_size; + int m_buffer_index; + float *m_buffer; // circular buffer +} t_prevl; + + +static void prevl_perform_float(t_prevl *x, t_float f) +{ + int index; + index=x->m_buffer_index+1; + index=(index==x->m_buffer_size)?0:index; + x->m_buffer_index=index; + x->m_buffer[index]=f; +} + +static void prevl_bang(t_prevl *x) +{ + int lo,hi,n,index,size; + t_atom *ap,*app; + float *buffer, *bp; + + lo=(int)x->m_lo; + hi=(int)x->m_hi; + + n=hi-lo; + size=x->m_buffer_size; + index=x->m_buffer_index; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + buffer=x->m_buffer; + bp=buffer+index-lo; + bp=(bp>=buffer)?bp:bp+size; // wrap + + if (bp-buffer>=n) + { // no wrap-around needed + index=n; + while(index--){ + SETFLOAT(app, *bp--); + app++; + } +// post("not wrapped, app-ap=%i",app-ap); + } + else // need to wrap + { + int ps, nn; + ps = bp-buffer; + nn=n; +// post(" nn=%i",nn); + for(;ps>=0;ps--) // don't we miss one sample in signal??? + { +// post("ps=%i",ps); + SETFLOAT(app, buffer[ps]); + app++; + nn--; + } + ps=size-1; +// post(" nn=%i",nn); + for(;nn>0;nn--) + { +// post("ps=%i",ps); + SETFLOAT(app, buffer[ps--]); + app++; + } + + } + + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void prevl_clear(t_prevl *x) +{ + int i,s; + float *f; + f=x->m_buffer; + s=x->m_buffer_size; + for (i=0;isize) + { + post("prevl: higher bound cannot be higher than the buffer size..."); + hi=size; + } + if (lo<0) + { + post("prevl: lower bound cannot be negative..."); + lo=0; + } + if (hi<1) + { + post("prevl: higher bound cannot be smaller than one..."); + hi=1; + } + if (hi<=lo) + { + post("prevl: higher bound must be higher than lower bound..."); + lo=hi-1.0f; + } + + freebytes(x->m_buffer, x->m_buffer_size); + + x->m_hi=(float)((int)hi); + x->m_lo=(float)((int)lo); + x->m_buffer_size=(int)size; + x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + prevl_clear(x); + x->m_buffer_index=0; +} + +static void *prevl_new(t_float lo, t_float hi, t_float size) +{ + t_prevl *x=(t_prevl *)pd_new(prevl_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_buffer_size=0; + x->m_buffer=0; + prevl_set(x, lo, hi, size); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + return (void *)x; +} + +static void prevl_free(t_prevl *x) +{ + freebytes(x->m_buffer, x->m_buffer_size); +} + +void prevl_setup(void) +{ + prevl_class = class_new(gensym("prevl"), + (t_newmethod)prevl_new, (t_method)prevl_free, + sizeof(t_prevl), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(prevl_class, (t_method)prevl_clear, gensym("clear"),0); + class_addfloat(prevl_class, (t_method)prevl_perform_float); + class_addbang(prevl_class, (t_method)prevl_bang); +} + diff --git a/smlib-meta.pd b/smlib-meta.pd new file mode 100644 index 0000000..0f3f90a --- /dev/null +++ b/smlib-meta.pd @@ -0,0 +1,16 @@ +#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 smlib; +#X text 10 50 AUTHOR Johannes Taelman ; +#X text 10 70 LICENSE GNU GPL; +#X text 10 90 DESCRIPTION vector processing, vector analysis, vector synthesis, number stream analysis, number stream filters; +#X restore 10 10 pd META; +#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 smlib; +#X text 10 50 AUTHOR Johannes Taelman ; +#X text 10 70 LICENSE GNU GPL; +#X text 10 90 DESCRIPTION vector processing, vector analysis, vector synthesis, number stream analysis, number stream filters; +#X restore 10 10 pd META; diff --git a/source/SMLib.c b/source/SMLib.c deleted file mode 100644 index baf4c8a..0000000 --- a/source/SMLib.c +++ /dev/null @@ -1,234 +0,0 @@ -/* --------------------- SMLib ----------------------------- */ -/* - - Signal processing for Mapping - objects: - - float stream - - pid controller? - - deltas (generate difference vector between current values and values of the past) - vector - - vquant (quantizer with hysteresis) - - vv/ - - vv> - - vv< - - s2v (stream to vector, incl ola) - - v2s (vector to stream, incl ola) - - vector math - - vreverse - - - delread - - delwrite - - upsample - - fir - - autorescale -*/ - -#include "defines.h" - - -// in alphabetical order -extern void bp_setup(); -extern void decimator_setup(); -extern void deltas_setup(); -extern void hip_setup(); -extern void hist_setup(); -extern void itov_setup(); -extern void lavg_setup(); -extern void lhist_setup(); -extern void lhisti_setup(); -extern void linspace_setup(); -extern void lmax_setup(); -extern void lmin_setup(); -extern void lrange_setup(); -extern void lstd_setup(); -extern void prevl_setup(); -extern void threshold_setup(); -extern void vabs_setup(); -extern void vclip_setup(); -extern void vcog_setup(); -extern void vdbtorms_setup(); -extern void vdelta_setup(); -extern void vfmod_setup(); -extern void vftom_setup(); -extern void vlavg_setup(); -extern void vlmax_setup(); -extern void vlmin_setup(); -extern void vlrange_setup(); -extern void vmax_setup(); -extern void vmin_setup(); -extern void vmtof_setup(); -extern void vpow_setup(); -extern void vrms_setup(); -extern void vrmstodb_setup(); -extern void vstd_setup(); -extern void vsum_setup(); -extern void vthreshold_setup(); -extern void vvconv_setup(); -extern void vvminus_setup(); -extern void vvplus_setup(); - -static t_class *SMLib_class; - -typedef struct _lstd -{ - t_object x_obj; -} t_SMLib; - -static void SMLib_help(t_SMLib *x) -{ - /* - */ - post(""); - post(""); - post(" .........................................................."); - post(" . SMLib ."); - post(" . Signal processing for Mapping ."); - post(" . v0.12 24/11/2002 ."); - post(" .........................................................."); - post(" . processing stream of floats (context) (float output) ."); - post(" . ."); - post(" . lavg leaky average ."); - post(" . lmax leaky maximum ."); - post(" . lmin leaky minimum ."); - post(" . lrange leaky range ."); - post(" u lstd leaky standard deviation ."); - post(" u decimator passes 1 in n input values ."); - post(" . threshold detection with hysteresis ."); - post(" . hip first order high-pass filter ."); - post(" . bp second order (resonant) high-pass filter ."); - post(" .........................................................."); - post(" . analyzing stream of floats (vector output) ."); - post(" . ."); - post(" . hist histogram ."); - post(" . lhist leaky histogram, clips samples ."); - post(" . lhisti leaky histogram, ignore samples ."); - post(" . outside bins ."); - post(" . itov bin index to value (for the histograms ."); - post(" . prevl previous floats in a list ."); - post(" . deltas difference between last float and ."); - post(" . previous floats ."); -// post(" o filterbank lineairly spaced set of bandpass filters ."); - post(" .........................................................."); - post(" . immediate vector analysis (float output) ."); - post(" . ."); - post(" . vsum sum of vector elements ."); - post(" . vcog center of gravity ."); - post(" . vmax maximum and its location ."); - post(" . vmin minimum and its location ."); - post(" . vrms root mean square ."); - post(" . vstd standard deviation ."); - post(" .........................................................."); - post(" . vector processors (vector output) ."); - post(" . ."); - post(" . vv+ vector addition ."); - post(" . vv- vector substraction ."); - post(" . vvconv vector convolution ."); - post(" . vclip clip elements ."); - post(" . vfmod floating point modulo ."); - post(" . vpow power ."); - post(" . vthreshold detections with hysteresises ."); - post(" . ."); - post(" . unit conversions on vectors ."); - post(" . ."); - post(" . vftom frequency to midi ."); - post(" . vmtof midi to frequency ."); - post(" . vdbtorms dB to rms ."); - post(" . vrmstodb rms to dB ."); - post(" .........................................................."); - post(" . vector synthesis (vector output) ."); - post(" . ."); - post(" . linspace linearly spaced vector ."); -// post(" o logspace logarithmically spaced vector ."); -// post(" o rand uniformly distributed random vector ."); -// post(" o randn normally distributed random vector ."); - post(" .........................................................."); - post(" . vector stream processing (vector output) (context) ."); - post(" . ."); - post(" . vlavg leaky averages ."); - post(" . vlmax leaky maxima ."); - post(" . vlmin leaky minima ."); - post(" . vlrange leaky ranges ."); - post(" . vdelta difference between successive vectors ."); - post(" .........................................................."); -// post(" . o = future additions ."); -// post(" . e = experimental ."); - post(" . u = undocumented ."); - post(" . j#|@ = johannes.taelman@rug.ac.be ."); - post(" .........................................................."); - post(""); - post(""); -} - -static void *SMLib_new() -{ - t_SMLib *x=(t_SMLib *)pd_new(SMLib_class); - return (void *)x; -} - -#ifdef WIN32 -__declspec(dllexport) void __cdecl SMLib_setup( void) -#else -void SMLib_setup( void) -#endif -{ - // dummy object for help-system - SMLib_class = class_new(gensym("SMLib"), - (t_newmethod)SMLib_new, 0, - sizeof(t_SMLib), - CLASS_DEFAULT, - 0); - class_addbang(SMLib_class, (t_method)SMLib_help); - class_addmethod(SMLib_class, (t_method)SMLib_help, gensym("help"),0); - - // real objects in alphabetical order - bp_setup(); - decimator_setup(); - deltas_setup(); - hip_setup(); - hist_setup(); - itov_setup(); - lavg_setup(); - lhist_setup(); - lhisti_setup(); - linspace_setup(); - lmax_setup(); - lmin_setup(); - lrange_setup(); - lstd_setup(); - prevl_setup(); - threshold_setup(); - vabs_setup(); - vclip_setup(); - vcog_setup(); - vdbtorms_setup(); - vdelta_setup(); - vfmod_setup(); - vftom_setup(); - vlavg_setup(); - vlmax_setup(); - vlmin_setup(); - vlrange_setup(); - vmax_setup(); - vmin_setup(); - vmtof_setup(); - vpow_setup(); - vrms_setup(); - vrmstodb_setup(); - vstd_setup(); - vsum_setup(); - vthreshold_setup(); - vvconv_setup(); - vvminus_setup(); - vvplus_setup(); - - post(""); - post(" .........................................................."); - post(" . SMLib ."); - post(" . Signal processing for Mapping ."); - post(" . v0.12 24/11/2002 ."); - post(" .........................................................."); - post(""); - -} diff --git a/source/SMLib.dsp b/source/SMLib.dsp deleted file mode 100755 index 35c2ab8..0000000 --- a/source/SMLib.dsp +++ /dev/null @@ -1,275 +0,0 @@ -# Microsoft Developer Studio Project File - Name="SMLib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=SMLib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "SMLib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "SMLib.mak" CFG="SMLib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "SMLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "SMLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "SMLib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x813 /d "NDEBUG" -# ADD RSC /l 0x813 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "SMLib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x813 /d "_DEBUG" -# ADD RSC /l 0x813 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "SMLib - Win32 Release" -# Name "SMLib - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\bp.c -# End Source File -# Begin Source File - -SOURCE=.\decimator.c -# End Source File -# Begin Source File - -SOURCE=.\deltas.c -# End Source File -# Begin Source File - -SOURCE=.\hip.c -# End Source File -# Begin Source File - -SOURCE=.\hist.c -# End Source File -# Begin Source File - -SOURCE=.\itov.c -# End Source File -# Begin Source File - -SOURCE=.\lavg.c -# End Source File -# Begin Source File - -SOURCE=.\lhist.c -# End Source File -# Begin Source File - -SOURCE=.\lhisti.c -# End Source File -# Begin Source File - -SOURCE=.\linspace.c -# End Source File -# Begin Source File - -SOURCE=.\lmax.c -# End Source File -# Begin Source File - -SOURCE=.\lmin.c -# End Source File -# Begin Source File - -SOURCE=.\lrange.c -# End Source File -# Begin Source File - -SOURCE=.\lstd.c -# End Source File -# Begin Source File - -SOURCE=.\prevl.c -# End Source File -# Begin Source File - -SOURCE=.\SMLib.c -# End Source File -# Begin Source File - -SOURCE=.\threshold.c -# End Source File -# Begin Source File - -SOURCE=.\vabs.c -# End Source File -# Begin Source File - -SOURCE=.\vclip.c -# End Source File -# Begin Source File - -SOURCE=.\vcog.c -# End Source File -# Begin Source File - -SOURCE=.\vdbtorms.c -# End Source File -# Begin Source File - -SOURCE=.\vdelta.c -# End Source File -# Begin Source File - -SOURCE=.\vfmod.c -# End Source File -# Begin Source File - -SOURCE=.\vftom.c -# End Source File -# Begin Source File - -SOURCE=.\vlavg.c -# End Source File -# Begin Source File - -SOURCE=.\vlmax.c -# End Source File -# Begin Source File - -SOURCE=.\vlmin.c -# End Source File -# Begin Source File - -SOURCE=.\vlrange.c -# End Source File -# Begin Source File - -SOURCE=.\vmax.c -# End Source File -# Begin Source File - -SOURCE=.\vmin.c -# End Source File -# Begin Source File - -SOURCE=.\vmtof.c -# End Source File -# Begin Source File - -SOURCE=.\vnmax.c -# End Source File -# Begin Source File - -SOURCE=.\vpow.c -# End Source File -# Begin Source File - -SOURCE=.\vrms.c -# End Source File -# Begin Source File - -SOURCE=.\vrmstodb.c -# End Source File -# Begin Source File - -SOURCE=.\vstd.c -# End Source File -# Begin Source File - -SOURCE=.\vsum.c -# End Source File -# Begin Source File - -SOURCE=.\vthreshold.c -# End Source File -# Begin Source File - -SOURCE=.\vvconv.c -# End Source File -# Begin Source File - -SOURCE=.\vvminus.c -# End Source File -# Begin Source File - -SOURCE=.\vvplus.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\defines.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\readme.txt -# End Source File -# End Target -# End Project diff --git a/source/SMLib.dsw b/source/SMLib.dsw deleted file mode 100755 index 0428bd3..0000000 --- a/source/SMLib.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "SMLib"=.\SMLib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/source/SMLib.opt b/source/SMLib.opt deleted file mode 100755 index 685315a..0000000 Binary files a/source/SMLib.opt and /dev/null differ diff --git a/source/SMLib.plg b/source/SMLib.plg deleted file mode 100755 index c75a641..0000000 --- a/source/SMLib.plg +++ /dev/null @@ -1,153 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: SMLib - Win32 Release-------------------- -

-

Command Lines

-Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" with contents -[ -/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /Fp"Release/SMLib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c -"D:\devel\SMLib\bp.c" -"D:\devel\SMLib\decimator.c" -"D:\devel\SMLib\deltas.c" -"D:\devel\SMLib\hip.c" -"D:\devel\SMLib\hist.c" -"D:\devel\SMLib\itov.c" -"D:\devel\SMLib\lavg.c" -"D:\devel\SMLib\lhist.c" -"D:\devel\SMLib\lhisti.c" -"D:\devel\SMLib\linspace.c" -"D:\devel\SMLib\lmax.c" -"D:\devel\SMLib\lmin.c" -"D:\devel\SMLib\lrange.c" -"D:\devel\SMLib\lstd.c" -"D:\devel\SMLib\prevl.c" -"D:\devel\SMLib\SMLib.c" -"D:\devel\SMLib\threshold.c" -"D:\devel\SMLib\vabs.c" -"D:\devel\SMLib\vclip.c" -"D:\devel\SMLib\vcog.c" -"D:\devel\SMLib\vdbtorms.c" -"D:\devel\SMLib\vdelta.c" -"D:\devel\SMLib\vfmod.c" -"D:\devel\SMLib\vftom.c" -"D:\devel\SMLib\vlavg.c" -"D:\devel\SMLib\vlmax.c" -"D:\devel\SMLib\vlmin.c" -"D:\devel\SMLib\vlrange.c" -"D:\devel\SMLib\vmax.c" -"D:\devel\SMLib\vmin.c" -"D:\devel\SMLib\vmtof.c" -"D:\devel\SMLib\vnmax.c" -"D:\devel\SMLib\vpow.c" -"D:\devel\SMLib\vrms.c" -"D:\devel\SMLib\vrmstodb.c" -"D:\devel\SMLib\vstd.c" -"D:\devel\SMLib\vsum.c" -"D:\devel\SMLib\vthreshold.c" -"D:\devel\SMLib\vvconv.c" -"D:\devel\SMLib\vvminus.c" -"D:\devel\SMLib\vvplus.c" -] -Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" -Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" with contents -[ -kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /incremental:no /pdb:"Release/SMLib.pdb" /machine:I386 /out:"Release/SMLib.dll" /implib:"Release/SMLib.lib" -.\Release\bp.obj -.\Release\decimator.obj -.\Release\deltas.obj -.\Release\hip.obj -.\Release\hist.obj -.\Release\itov.obj -.\Release\lavg.obj -.\Release\lhist.obj -.\Release\lhisti.obj -.\Release\linspace.obj -.\Release\lmax.obj -.\Release\lmin.obj -.\Release\lrange.obj -.\Release\lstd.obj -.\Release\prevl.obj -.\Release\SMLib.obj -.\Release\threshold.obj -.\Release\vabs.obj -.\Release\vclip.obj -.\Release\vcog.obj -.\Release\vdbtorms.obj -.\Release\vdelta.obj -.\Release\vfmod.obj -.\Release\vftom.obj -.\Release\vlavg.obj -.\Release\vlmax.obj -.\Release\vlmin.obj -.\Release\vlrange.obj -.\Release\vmax.obj -.\Release\vmin.obj -.\Release\vmtof.obj -.\Release\vnmax.obj -.\Release\vpow.obj -.\Release\vrms.obj -.\Release\vrmstodb.obj -.\Release\vstd.obj -.\Release\vsum.obj -.\Release\vthreshold.obj -.\Release\vvconv.obj -.\Release\vvminus.obj -.\Release\vvplus.obj -] -Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" -

Output Window

-Compiling... -bp.c -decimator.c -deltas.c -hip.c -hist.c -itov.c -lavg.c -lhist.c -lhisti.c -linspace.c -lmax.c -lmin.c -lrange.c -lstd.c -prevl.c -SMLib.c -threshold.c -vabs.c -vclip.c -vcog.c -vdbtorms.c -vdelta.c -vfmod.c -vftom.c -vlavg.c -vlmax.c -vlmin.c -vlrange.c -vmax.c -vmin.c -vmtof.c -vnmax.c -vpow.c -vrms.c -vrmstodb.c -vstd.c -vsum.c -vthreshold.c -vvconv.c -vvminus.c -vvplus.c -Linking... - Creating library Release/SMLib.lib and object Release/SMLib.exp - - - -

Results

-SMLib.dll - 0 error(s), 0 warning(s) -
- - diff --git a/source/bp.c b/source/bp.c deleted file mode 100644 index d21bc19..0000000 --- a/source/bp.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "defines.h" - -/*--------------- bp ---------------*/ - -typedef struct bpctl -{ - float c_x1; - float c_x2; - float c_coef1; - float c_coef2; - float c_gain; -} t_bpctl; - -typedef struct bp -{ - t_object x_obj; - float x_freq; - float x_q; - t_bpctl x_cspace; - t_bpctl *x_ctl; - float x_f; -} t_bp; - -t_class *bp_class; - -static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q); - -static void *bp_new(t_floatarg f, t_floatarg q) -{ - t_bp *x = (t_bp *)pd_new(bp_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2")); - outlet_new(&x->x_obj, gensym("float")); - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x1 = 0; - x->x_cspace.c_x2 = 0; - bp_docoef(x, f, q); - x->x_f = 0; - return (x); -} - -static float bp_qcos(float f) -{ - if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f) - { - float g = f*f; - return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5f) + 1); - } - else return (0); -} - -static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q) -{ - float r, oneminusr, omega; - if (f < 0.0001f) f = 0.0001f; - if (q < 0) q = 0; - x->x_freq = f; - x->x_q = q; - omega = f * (2.0f * 3.14159f); - if (q < 0.001) oneminusr = 1.0f; - else oneminusr = omega/q; - if (oneminusr > 1.0f) oneminusr = 1.0f; - r = 1.0f - oneminusr; - x->x_ctl->c_coef1 = 2.0f * bp_qcos(omega) * r; - x->x_ctl->c_coef2 = - r * r; - x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega); - /* post("r %f, omega %f, coef1 %f, coef2 %f", - r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */ -} - -static void bp_ft1(t_bp *x, t_floatarg f) -{ - bp_docoef(x, f, x->x_q); -} - -static void bp_ft2(t_bp *x, t_floatarg q) -{ - bp_docoef(x, x->x_freq, q); -} - -static void bp_clear(t_bp *x, t_floatarg q) -{ - x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0; -} - -static void bp_perform(t_bp *x, t_float in) -{ - float out; - t_bpctl *c = x->x_ctl; - float last = c->c_x1; - float prev = c->c_x2; - float coef1 = c->c_coef1; - float coef2 = c->c_coef2; - float gain = c->c_gain; - - float output = in + coef1 * last + coef2 * prev; - out = gain * output; - - prev = last; - last = output; - - /* NAN protect */ - if (!((last <= 0) || (last >= 0))) - last = 0; - if (!((prev <= 0) || (prev >= 0))) - prev = 0; - c->c_x1 = last; - c->c_x2 = prev; - - outlet_float(x->x_obj.ob_outlet, out); -} - -void bp_setup(void) -{ - bp_class = class_new(gensym("bp"), (t_newmethod)bp_new, 0, - sizeof(t_bp), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - class_addfloat(bp_class, (t_method)bp_perform); - class_addmethod(bp_class, (t_method)bp_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(bp_class, (t_method)bp_ft2, - gensym("ft2"), A_FLOAT, 0); - class_addmethod(bp_class, (t_method)bp_clear, gensym("clear"), 0); -} diff --git a/source/decimator.c b/source/decimator.c deleted file mode 100644 index d7f93f3..0000000 --- a/source/decimator.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "defines.h" - -/*--------------- decimator ---------------*/ - -static t_class *decimator_class; - -typedef struct _decimator -{ - t_object x_obj; - int m_state; - int m_factor; -} t_decimator; - -static void decimator_perform(t_decimator *x, t_float in) -{ - if (!x->m_state) - { - outlet_float(x->x_obj.ob_outlet, in); - x->m_state=x->m_factor; - } - else - { - x->m_state--; - } - -} - -static void decimator_setFactor(t_decimator *x, t_float factor) -{ - x->m_factor=(int)factor - 1; -} - -static void decimator_clear(t_decimator *x) -{ - x->m_state=0; -} - - -static void *decimator_new(t_float factor) -{ - - t_decimator *x=(t_decimator *)pd_new(decimator_class); - outlet_new(&x->x_obj, gensym("float")); - - if (factor<1) factor=2; - - decimator_setFactor(x, factor); - decimator_clear(x); - return (void *)x; -} - - -void decimator_setup(void) -{ - decimator_class = class_new(gensym("decimator"), - (t_newmethod)decimator_new, 0, - sizeof(t_decimator), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(decimator_class, (t_method)decimator_perform); - class_addmethod(decimator_class, (t_method)decimator_clear, - gensym("clear"), A_GIMME, NULL); - class_addmethod(decimator_class, (t_method)decimator_setFactor, - gensym("factor"), A_DEFFLOAT, NULL); -} - diff --git a/source/defines.h b/source/defines.h deleted file mode 100644 index ecc208b..0000000 --- a/source/defines.h +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include "m_imp.h" -#include -#define MAXFLOAT 1e18f; -#define LOGTEN 2.302585092994 - -/* NT and OSX don't appear to have single-precision ANSI math */ -#if defined(WIN32) || defined(__APPLE__) -#define sinf sin -#define cosf cos -#define atanf atan -#define atan2f atan2 -#define sqrtf sqrt -#define logf log -#define expf exp -#define fabsf fabs -#define powf pow -#endif diff --git a/source/deltas.c b/source/deltas.c deleted file mode 100644 index edc3cb0..0000000 --- a/source/deltas.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "defines.h" - -/*--------------- deltas ---------------*/ - -static t_class *deltas_class; - -typedef struct _deltas -{ - t_object x_obj; - float m_lo; - float m_hi; - int m_buffer_size; - int m_buffer_index; - float *m_buffer; // circular buffer -} t_deltas; - - -static void deltas_perform_float(t_deltas *x, t_float f) -{ - int index; - index=x->m_buffer_index+1; - index=(index==x->m_buffer_size)?0:index; - x->m_buffer_index=index; - x->m_buffer[index]=f; -} - -static void deltas_bang(t_deltas *x) -{ - int lo,hi,n,index,size; - t_atom *ap,*app; - float last; - float *buffer, *bp; - - lo=(int)x->m_lo; - hi=(int)x->m_hi; - - n=hi-lo; - size=x->m_buffer_size; - index=x->m_buffer_index; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - buffer=x->m_buffer; - last=buffer[index]; - bp=buffer+index-lo; - bp=(bp>=buffer)?bp:bp+size; // wrap - - if (bp-buffer>=n) - { // no wrap-around needed - index=n; - while(index--){ - SETFLOAT(app, last-*bp--); - app++; - } -// post("not wrapped, app-ap=%i",app-ap); - } - else // need to wrap - { - int ps, nn; - ps = bp-buffer; - nn=n; -// post(" nn=%i",nn); - for(;ps>=0;ps--) // don't we miss one sample in signal??? - { -// post("ps=%i",ps); - SETFLOAT(app, last-buffer[ps]); - app++; - nn--; - } - ps=size-1; -// post(" nn=%i",nn); - for(;nn>0;nn--) - { -// post("ps=%i",ps); - SETFLOAT(app, last-buffer[ps--]); - app++; - } - -/* - int i2; - index=bp-buffer; - i2=index; - post("first part %i",index); - while(index--){ - SETFLOAT(app, last-*bp--); - app++; - } - index=n-i2; - post("2nd part %i",index); - bp=buffer+size-1; - while(index--){ - SETFLOAT(app, last-*bp--); - app++; - } -*/ -// post("wrapped, app-ap=%i",app-ap); - } - - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap, sizeof(t_atom)*n); -} - -static void deltas_clear(t_deltas *x) -{ - int i,s; - float *f; - f=x->m_buffer; - s=x->m_buffer_size; - for (i=0;isize) - { - post("deltas: higher bound cannot be higher than the buffer size..."); - hi=size; - } - if (lo<0) - { - post("deltas: lower bound cannot be negative..."); - lo=0; - } - if (hi<1) - { - post("deltas: higher bound cannot be smaller than one..."); - hi=1; - } - if (hi<=lo) - { - post("deltas: higher bound must be higher than lower bound..."); - lo=hi-1.0f; - } - - freebytes(x->m_buffer, x->m_buffer_size); - - x->m_hi=(float)((int)hi); - x->m_lo=(float)((int)lo); - x->m_buffer_size=(int)size; - x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); - deltas_clear(x); - x->m_buffer_index=0; -} - -static void *deltas_new(t_float lo, t_float hi, t_float size) -{ - t_deltas *x=(t_deltas *)pd_new(deltas_class); - outlet_new(&x->x_obj, gensym("list")); - x->m_buffer_size=0; - x->m_buffer=0; - deltas_set(x, lo, hi, size); - - floatinlet_new(&x->x_obj, &x->m_lo); - floatinlet_new(&x->x_obj, &x->m_hi); - - return (void *)x; -} - -static void deltas_free(t_deltas *x) -{ - freebytes(x->m_buffer, x->m_buffer_size); -} - -void deltas_setup(void) -{ - deltas_class = class_new(gensym("deltas"), - (t_newmethod)deltas_new, (t_method)deltas_free, - sizeof(t_deltas), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); - - class_addmethod(deltas_class, (t_method)deltas_clear, gensym("clear"),0); - class_addfloat(deltas_class, (t_method)deltas_perform_float); - class_addbang(deltas_class, (t_method)deltas_bang); -} - diff --git a/source/hip.c b/source/hip.c deleted file mode 100644 index b1425c1..0000000 --- a/source/hip.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "defines.h" - -/*--------------- hip ---------------*/ - -typedef struct hipctl -{ - float c_x; - float c_coef; -} t_hipctl; - -typedef struct hip -{ - t_object x_obj; - float x_sr; - float x_hz; - t_hipctl x_cspace; - t_hipctl *x_ctl; - float x_f; -} t_hip; - -t_class *hip_class; - -static void hip_ft1(t_hip *x, t_floatarg f); - -static void *hip_new(t_floatarg f) -{ - t_hip *x = (t_hip *)pd_new(hip_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - outlet_new(&x->x_obj, gensym("float")); - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x = 0; - hip_ft1(x, f); - x->x_f = 0; - return (x); -} - -static void hip_ft1(t_hip *x, t_floatarg f) -{ - if (f < 0.001) f = 10; - x->x_hz = f; - x->x_ctl->c_coef = 1 - f * (2 * 3.14159f); - if (x->x_ctl->c_coef < 0) x->x_ctl->c_coef = 0; -} - -static void hip_perform(t_hip *x, t_float in) -{ - t_hipctl *c = x->x_ctl; - float last = c->c_x; - float coef = c->c_coef; - float out; - - float new = in + coef * last; - out = new - last; - last = new; - - /* NAN protect */ - if (!((last <= 0) || (last >= 0))) - last = 0; - c->c_x = last; - - outlet_float(x->x_obj.ob_outlet, out); -} - -static void hip_clear(t_hip *x, t_floatarg q) -{ - x->x_cspace.c_x = 0; -} - -void hip_setup(void) -{ - hip_class = class_new(gensym("hip"), (t_newmethod)hip_new, 0, - sizeof(t_hip), 0, A_DEFFLOAT, 0); - class_addfloat(hip_class, (t_method)hip_perform); - class_addmethod(hip_class, (t_method)hip_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(hip_class, (t_method)hip_clear, gensym("clear"), 0); -} \ No newline at end of file diff --git a/source/hist.c b/source/hist.c deleted file mode 100644 index ba492f2..0000000 --- a/source/hist.c +++ /dev/null @@ -1,155 +0,0 @@ -#include "defines.h" - -/*--------------- hist ---------------*/ - - -static t_class *hist_class; - -typedef struct _hist -{ - t_object x_obj; - float m_lo; - float m_hi; - float m_scale; - int m_nbins; - int m_n_observations; - float *m_hist; -} t_hist; - - -static void hist_perform_float(t_hist *x, t_float f) -{ - int j; - j=(int)(.5+(f-x->m_lo)*x->m_scale); - j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF - x->m_hist[j]++; - x->m_n_observations++; -} - -static void hist_perform_list(t_hist *x, t_symbol *s, int argc, t_atom *argv) -{ - int i,j; - for (i = 0; i < argc; i++) - { - j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); - j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF - x->m_hist[j]++; - } - x->m_n_observations+=argc; -} - -static void hist_bang(t_hist *x) -{ - int i,n; - float *f; - t_atom *ap,*app; - - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - - i=x->m_nbins; - f=x->m_hist; - - while(i--){ - SETFLOAT(app, *f); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap, sizeof(t_atom)*n); -} - -static void hist_relative(t_hist *x) -{ - int i,n; - float *f; - float invn; - t_atom *ap,*app; - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - - invn=1.0f/(1e-10f+x->m_n_observations); - - i=n; - f=x->m_hist; - - while(i--){ - SETFLOAT(app, (*f*invn)); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap, sizeof(t_atom)*n); -} - -static void hist_clear(t_hist *x) -{ - int i; - float *f; - f=x->m_hist; - for (i=0;im_nbins;i++) - *f++=0.0f; - x->m_n_observations=0; -} - - -static void hist_set(t_hist *x, t_float lo, t_float hi, t_float nbins) -{ - if (nbins<1) - { - nbins=1; - post("hist: number of bins is minimum 1..."); - } - if (hi<=lo) - { - post("hist: higher bound must be higher than lower bound..."); - hi=lo+1.0f; - } - - freebytes(x->m_hist, x->m_nbins); - - x->m_hi=hi; - x->m_lo=lo; - x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_hist = (float*)getbytes(sizeof(float)*x->m_nbins); - - hist_clear(x); -} - -static void *hist_new(t_float lo, t_float hi, t_float nbins) -{ - t_hist *x=(t_hist *)pd_new(hist_class); - outlet_new(&x->x_obj, gensym("list")); - x->m_hist=0; - x->m_nbins=0; - hist_set(x, lo, hi, nbins); - return (void *)x; -} - -static void hist_free(t_hist *x) -{ - freebytes(x->m_hist, x->m_nbins); -} - -void hist_setup(void) -{ - hist_class = class_new(gensym("hist"), - (t_newmethod)hist_new, (t_method)hist_free, - sizeof(t_hist), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); - - class_addmethod(hist_class, (t_method)hist_clear, gensym("clear"),0); - class_addmethod(hist_class, (t_method)hist_bang, gensym("absolute"),0); - class_addmethod(hist_class, (t_method)hist_relative, gensym("relative"),0); - - class_addmethod(hist_class, (t_method)hist_set, gensym("set"),A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); - - class_addlist(hist_class, (t_method)hist_perform_list); - class_addfloat(hist_class, (t_method)hist_perform_float); - class_addbang(hist_class, (t_method)hist_bang); -} - diff --git a/source/itov.c b/source/itov.c deleted file mode 100644 index fa68a90..0000000 --- a/source/itov.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "defines.h" - -/*--------------- itov ---------------*/ - - -static t_class *itov_class; - -typedef struct _itov -{ - t_object x_obj; - t_outlet *f_out1; - t_outlet *f_out2; - t_outlet *f_out3; - float m_lo; - float m_hi; - float m_scale; - int m_nbins; -} t_itov; - - -static void itov_perform_float(t_itov *x, t_float j) -{ - float i; - j-=1.0f; - j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF - -// j=(int)((f-x->m_lo)*x->m_scale); - i=(j/x->m_scale)-x->m_lo; - - outlet_float(x->f_out2, i); - -} - -static void itov_perform_list(t_itov *x, t_symbol *s, int argc, t_atom *argv) -{ - - -} - -static void itov_set(t_itov *x, t_float lo, t_float hi, t_float nbins) -{ - if (nbins<1) - { - nbins=1; - post("itov: number of bins is minimum 1..."); - } - if (hi<=lo) - { - post("itov: higher bound must be higher than lower bound..."); - hi=lo+1.0f; - } - - x->m_hi=hi; - x->m_lo=lo; - x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); -} - -static void *itov_new(t_float lo, t_float hi, t_float nbins) -{ - t_itov *x=(t_itov *)pd_new(itov_class); - x->f_out1=outlet_new(&x->x_obj, gensym("float")); - x->f_out2=outlet_new(&x->x_obj, gensym("float")); - x->f_out3=outlet_new(&x->x_obj, gensym("float")); - - x->m_nbins=0; - itov_set(x, lo, hi, nbins); - return (void *)x; -} - -static void itov_free(t_itov *x) -{ -} - -void itov_setup(void) -{ - itov_class = class_new(gensym("itov"), - (t_newmethod)itov_new, (t_method)itov_free, - sizeof(t_itov), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); - -// class_addlist(itov_class, (t_method)itov_perform_list); - class_addfloat(itov_class, (t_method)itov_perform_float); -} - diff --git a/source/lavg.c b/source/lavg.c deleted file mode 100644 index fce0015..0000000 --- a/source/lavg.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "defines.h" - -/*--------------- lavg ---------------*/ - -static t_class *lavg_class; - -typedef struct _lavg -{ - t_object x_obj; - float m_avg; - float m_c_leak; - float m_leak; -} t_lavg; - - -static void lavg_perform(t_lavg *x, t_float in) -{ - x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; - outlet_float(x->x_obj.ob_outlet, x->m_avg); -} - -static void lavg_clear(t_lavg *x) -{ - x->m_avg=0.0f; -} - -static void lavg_setHalfDecay(t_lavg *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void *lavg_new( t_float halfDecayTime) -{ - t_lavg *x=(t_lavg *)pd_new(lavg_class); - outlet_new(&x->x_obj, gensym("float")); - - lavg_setHalfDecay(x, halfDecayTime); - return (void *)x; -} - -void lavg_setup(void) -{ - lavg_class = class_new(gensym("lavg"), - (t_newmethod)lavg_new, 0, - sizeof(t_lavg), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(lavg_class, (t_method)lavg_perform); - class_addmethod(lavg_class, (t_method)lavg_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - class_addmethod(lavg_class, (t_method)lavg_clear, - gensym("clear"), 0); -} - diff --git a/source/lhist.c b/source/lhist.c deleted file mode 100644 index ea20edc..0000000 --- a/source/lhist.c +++ /dev/null @@ -1,174 +0,0 @@ -#include "defines.h" - -/*--------------- lhist ---------------*/ - -static t_class *lhist_class; - -typedef struct _lhist -{ - t_object x_obj; - float m_lo; - float m_hi; - float m_scale; - float m_c_leak; - float m_leak; - int m_nbins; -// int m_n_observations; - float *m_lhist; -} t_lhist; - -static void lhist_setHalfDecay(t_lhist *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lhist_perform_float(t_lhist *x, t_float f) -{ - int j; - j=(int)(.5+(f-x->m_lo)*x->m_scale); - j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF - x->m_lhist[j]++; -// x->m_n_observations++; -} - -static void lhist_perform_list(t_lhist *x, t_symbol *s, int argc, t_atom *argv) -{ - int i,j; - for (i = 0; i < argc; i++) - { - j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); - j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF - x->m_lhist[j]++; - } -// x->m_n_observations+=argc; -} - -static void lhist_leak(t_lhist *x) -{ - int i; - float *f; - float sc; - f=x->m_lhist; - sc=x->m_c_leak; - i=x->m_nbins; - while(i--) - *f++*=sc; -} - -static void lhist_bang(t_lhist *x) -{ - int i,n; - float *f; - t_atom *ap,*app; - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - i=n; - f=x->m_lhist; - - while(i--){ - SETFLOAT(app, *f); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap,n); -} - -static void lhist_relative(t_lhist *x) -{ - int i,n; - float *f; - float invn,sum; - t_atom *ap,*app; - - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - i=x->m_nbins; - f=x->m_lhist; - sum=0.0f; - while(i--) sum+=*f++; - invn=1.0f/(1e-10f+sum); - - i=x->m_nbins; - f=x->m_lhist; - - while(i--){ - SETFLOAT(app, (*f*invn)); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap,n); -} - -static void lhist_clear(t_lhist *x) -{ - int i; - float *f; - f=x->m_lhist; - for (i=0;im_nbins;i++) - *f++=0.0f; -// x->m_n_observations=0; -} - -static void lhist_set(t_lhist *x, t_float lo, t_float hi, t_float nbins) -{ - if (nbins<1) - { - nbins=1; - post("lhist: number of bins is minimum 1..."); - } - if (hi<=lo) - { - post("lhist: higher bound must be higher than lower bound..."); - hi=lo+1.0f; - } - freebytes(x->m_lhist, x->m_nbins); - x->m_hi=hi; - x->m_lo=lo; - x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_lhist = (float*)getbytes(sizeof(float)*x->m_nbins); - - lhist_clear(x); -} - -static void *lhist_new(t_float lo, t_float hi, t_float nbins, t_float decay) -{ - t_lhist *x=(t_lhist *)pd_new(lhist_class); - outlet_new(&x->x_obj, gensym("list")); - lhist_setHalfDecay(x,decay); - x->m_nbins=0; - x->m_lhist=0; - lhist_set(x, lo, hi, nbins); - return (void *)x; -} - -static void lhist_free(t_lhist *x) -{ - freebytes(x->m_lhist, x->m_nbins); -} - -void lhist_setup(void) -{ - lhist_class = class_new(gensym("lhist"), - (t_newmethod)lhist_new, (t_method)lhist_free, - sizeof(t_lhist), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); - - class_addmethod(lhist_class, (t_method)lhist_clear, gensym("clear"),0); - class_addmethod(lhist_class, (t_method)lhist_bang, gensym("absolute"),0); - class_addmethod(lhist_class, (t_method)lhist_relative, gensym("relative"),0); - class_addmethod(lhist_class, (t_method)lhist_leak, gensym("leak"),0); - class_addmethod(lhist_class, (t_method)lhist_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - - class_addlist(lhist_class, (t_method)lhist_perform_list); - class_addfloat(lhist_class, (t_method)lhist_perform_float); - class_addbang(lhist_class, (t_method)lhist_bang); -} - diff --git a/source/lhisti.c b/source/lhisti.c deleted file mode 100644 index 826cce4..0000000 --- a/source/lhisti.c +++ /dev/null @@ -1,174 +0,0 @@ -#include "defines.h" - -/*--------------- lhisti ---------------*/ -// ignores samples outside bins - -static t_class *lhisti_class; - -typedef struct _lhisti -{ - t_object x_obj; - float m_lo; - float m_hi; - float m_scale; - float m_c_leak; - float m_leak; - int m_nbins; -// int m_n_observations; - float *m_lhisti; -} t_lhisti; - -static void lhisti_setHalfDecay(t_lhisti *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lhisti_perform_float(t_lhisti *x, t_float f) -{ - int j; - j=(int)(.5+(f-x->m_lo)*x->m_scale); - if ((j>=0)&&(jm_nbins)) - x->m_lhisti[j]++; -} - -static void lhisti_perform_list(t_lhisti *x, t_symbol *s, int argc, t_atom *argv) -{ - int i,j; - for (i = 0; i < argc; i++) - { - j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); - if ((j>=0)&&(jm_nbins)) - x->m_lhisti[j]++; - } -// x->m_n_observations+=argc; -} - -static void lhisti_leak(t_lhisti *x) -{ - int i; - float *f; - float sc; - f=x->m_lhisti; - sc=x->m_c_leak; - i=x->m_nbins; - while(i--) - *f++*=sc; -} - -static void lhisti_bang(t_lhisti *x) -{ - int i,n; - float *f; - t_atom *ap,*app; - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - i=n; - f=x->m_lhisti; - - while(i--){ - SETFLOAT(app, *f); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap,n); -} - -static void lhisti_relative(t_lhisti *x) -{ - int i,n; - float *f; - float invn,sum; - t_atom *ap,*app; - - n=x->m_nbins; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - i=x->m_nbins; - f=x->m_lhisti; - sum=0.0f; - while(i--) sum+=*f++; - invn=1.0f/(1e-10f+sum); - - i=x->m_nbins; - f=x->m_lhisti; - - while(i--){ - SETFLOAT(app, (*f*invn)); - f++; - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap,n); -} - -static void lhisti_clear(t_lhisti *x) -{ - int i; - float *f; - f=x->m_lhisti; - for (i=0;im_nbins;i++) - *f++=0.0f; -// x->m_n_observations=0; -} - -static void lhisti_set(t_lhisti *x, t_float lo, t_float hi, t_float nbins) -{ - if (nbins<1) - { - nbins=1; - post("lhisti: number of bins is minimum 1..."); - } - if (hi<=lo) - { - post("lhisti: higher bound must be higher than lower bound..."); - hi=lo+1.0f; - } - freebytes(x->m_lhisti, x->m_nbins); - x->m_hi=hi; - x->m_lo=lo; - x->m_nbins=(int)nbins; - x->m_scale=(float)x->m_nbins/(hi-lo); - x->m_lhisti = (float*)getbytes(sizeof(float)*x->m_nbins); - - lhisti_clear(x); -} - -static void *lhisti_new(t_float lo, t_float hi, t_float nbins, t_float decay) -{ - t_lhisti *x=(t_lhisti *)pd_new(lhisti_class); - outlet_new(&x->x_obj, gensym("list")); - lhisti_setHalfDecay(x,decay); - x->m_nbins=0; - x->m_lhisti=0; - lhisti_set(x, lo, hi, nbins); - return (void *)x; -} - -static void lhisti_free(t_lhisti *x) -{ - freebytes(x->m_lhisti, x->m_nbins); -} - -void lhisti_setup(void) -{ - lhisti_class = class_new(gensym("lhisti"), - (t_newmethod)lhisti_new, (t_method)lhisti_free, - sizeof(t_lhisti), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); - - class_addmethod(lhisti_class, (t_method)lhisti_clear, gensym("clear"),0); - class_addmethod(lhisti_class, (t_method)lhisti_bang, gensym("absolute"),0); - class_addmethod(lhisti_class, (t_method)lhisti_relative, gensym("relative"),0); - class_addmethod(lhisti_class, (t_method)lhisti_leak, gensym("leak"),0); - class_addmethod(lhisti_class, (t_method)lhisti_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - - class_addlist(lhisti_class, (t_method)lhisti_perform_list); - class_addfloat(lhisti_class, (t_method)lhisti_perform_float); - class_addbang(lhisti_class, (t_method)lhisti_bang); -} - diff --git a/source/linspace.c b/source/linspace.c deleted file mode 100644 index c3af9c2..0000000 --- a/source/linspace.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "defines.h" - -/*--------------- linspace ----------------*/ -/* clips a vector */ - - -static t_class *linspace_class; - -typedef struct _linspace -{ - t_object x_obj; - float m_lo; - float m_hi; - float m_n; -} t_linspace; - - -static void linspace_bang(t_linspace *x) -{ - int n; - n=(int)x->m_n; - if ((n<256)&&(n>1)) - { - int i; - float lo,step; - t_atom *ap,*app; - - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - lo=x->m_lo; - step=(x->m_hi-lo)/(n-1); - for (i = 0; i < n; i++) - { - - SETFLOAT(app, lo); - app++; - lo+=step; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap,n); - } -} - -static void linspace_float(t_linspace *x, t_float lo) -{ - x->m_lo=lo; - linspace_bang(x); -} - -static void *linspace_new(t_float lo, t_float hi, t_float n) -{ - t_linspace *x=(t_linspace *)pd_new(linspace_class); - - floatinlet_new(&x->x_obj, &x->m_hi); - floatinlet_new(&x->x_obj, &x->m_n); - - outlet_new(&x->x_obj, gensym("list")); - x->m_lo=lo; - x->m_hi=hi; - x->m_n=n; - return (void *)x; -} - -void linspace_setup(void) -{ - linspace_class = class_new(gensym("linspace"), - (t_newmethod)linspace_new, 0, - sizeof(t_linspace), - CLASS_DEFAULT, - A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); - class_addfloat(linspace_class, (t_method)linspace_float); - class_addbang(linspace_class, (t_method)linspace_bang); -} - diff --git a/source/lmax.c b/source/lmax.c deleted file mode 100644 index 911304f..0000000 --- a/source/lmax.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "defines.h" - -/*--------------- lmax ---------------*/ - -static t_class *lmax_class; - -typedef struct _lmax -{ - t_object x_obj; - float m_max; - float m_leak; - float m_c_leak; -} t_lmax; - - -static void lmax_perform(t_lmax *x, t_float in) -{ - x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; - outlet_float(x->x_obj.ob_outlet, x->m_max); -} - -static void lmax_setHalfDecay(t_lmax *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lmax_clear(t_lmax *x) -{ - x->m_max= - MAXFLOAT; -} - -static void *lmax_new( t_float halfDecayTime) -{ - t_lmax *x=(t_lmax *)pd_new(lmax_class); - outlet_new(&x->x_obj, gensym("float")); - - lmax_setHalfDecay(x, halfDecayTime); - lmax_clear(x); - return (void *)x; -} - - -void lmax_setup(void) -{ - lmax_class = class_new(gensym("lmax"), - (t_newmethod)lmax_new, 0, - sizeof(t_lmax), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(lmax_class, (t_method)lmax_perform); - class_addmethod(lmax_class, (t_method)lmax_clear, - gensym("clear"), A_GIMME, NULL); - class_addmethod(lmax_class, (t_method)lmax_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); -} - diff --git a/source/lmin.c b/source/lmin.c deleted file mode 100644 index 51b333a..0000000 --- a/source/lmin.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "defines.h" - -/*--------------- lmin ---------------*/ - -static t_class *lmin_class; - -typedef struct _lmin -{ - t_object x_obj; - float m_min; - float m_leak; - float m_c_leak; -} t_lmin; - - -static void lmin_perform(t_lmin *x, t_float in) -{ - x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; - outlet_float(x->x_obj.ob_outlet, x->m_min); -} - -static void lmin_setHalfDecay(t_lmin *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lmin_clear(t_lmin *x) -{ - x->m_min= MAXFLOAT; -} - -static void *lmin_new( t_float halfDecayTime) -{ - t_lmin *x=(t_lmin *)pd_new(lmin_class); - outlet_new(&x->x_obj, gensym("float")); - - lmin_setHalfDecay(x, halfDecayTime); - lmin_clear(x); - return (void *)x; -} - - -void lmin_setup(void) -{ - lmin_class = class_new(gensym("lmin"), - (t_newmethod)lmin_new, 0, - sizeof(t_lmin), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(lmin_class, (t_method)lmin_perform); - class_addmethod(lmin_class, (t_method)lmin_clear, - gensym("clear"), A_GIMME, NULL); - class_addmethod(lmin_class, (t_method)lmin_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); -} - diff --git a/source/lrange.c b/source/lrange.c deleted file mode 100644 index 8f5b296..0000000 --- a/source/lrange.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "defines.h" - -/*--------------- lrange ---------------*/ - -static t_class *lrange_class; - -typedef struct _lrange -{ - t_object x_obj; - float m_min; - float m_max; - float m_c_leak; - float m_leak; -} t_lrange; - - -static void lrange_perform(t_lrange *x, t_float in) -{ - x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; - x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; - outlet_float(x->x_obj.ob_outlet, x->m_max-x->m_min); -} - -static void lrange_setHalfDecay(t_lrange *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lrange_clear(t_lrange *x) -{ - x->m_max = - MAXFLOAT; - x->m_min = MAXFLOAT; -} - -static void *lrange_new( t_float halfDecayTime) -{ - t_lrange *x=(t_lrange *)pd_new(lrange_class); - outlet_new(&x->x_obj, gensym("float")); - - lrange_setHalfDecay(x, halfDecayTime); - lrange_clear(x); - return (void *)x; -} - - -void lrange_setup(void) -{ - lrange_class = class_new(gensym("lrange"), - (t_newmethod)lrange_new, 0, - sizeof(t_lrange), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(lrange_class, (t_method)lrange_perform); - class_addmethod(lrange_class, (t_method)lrange_clear, - gensym("clear"), A_GIMME, NULL); - class_addmethod(lrange_class, (t_method)lrange_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); -} - diff --git a/source/lstd.c b/source/lstd.c deleted file mode 100644 index 1873bda..0000000 --- a/source/lstd.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "defines.h" - -/*--------------- lstd ---------------*/ - -static t_class *lstd_class; - -typedef struct _lstd -{ - t_object x_obj; - float m_avg; - float m_sum_squares; - float m_std; - float m_c_leak; - float m_leak; -} t_lstd; - - -static void lstd_perform(t_lstd *x, t_float in) -{ - float tmp=x->m_avg-in; - x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; - x->m_sum_squares=x->m_sum_squares * x->m_c_leak + x->m_leak*tmp*tmp; - x->m_std=(float)sqrtf(x->m_sum_squares); - outlet_float(x->x_obj.ob_outlet, x->m_std); -} - -static void lstd_setHalfDecay(t_lstd *x, t_float halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void lstd_clear(t_lstd *x) -{ - x->m_sum_squares=0.0f; - x->m_avg=0.0f; -} - -static void *lstd_new( t_float halfDecayTime) -{ - t_lstd *x=(t_lstd *)pd_new(lstd_class); - outlet_new(&x->x_obj, gensym("float")); - - lstd_setHalfDecay(x, halfDecayTime); - return (void *)x; -} - - -void lstd_setup(void) -{ - lstd_class = class_new(gensym("lstd"), - (t_newmethod)lstd_new, 0, - sizeof(t_lstd), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addfloat(lstd_class, (t_method)lstd_perform); - class_addmethod(lstd_class, (t_method)lstd_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); -} - diff --git a/source/prevl.c b/source/prevl.c deleted file mode 100644 index 2ba39ce..0000000 --- a/source/prevl.c +++ /dev/null @@ -1,161 +0,0 @@ -#include "defines.h" - -/*--------------- prevl ---------------*/ - -static t_class *prevl_class; - -typedef struct _prevl -{ - t_object x_obj; - float m_lo; - float m_hi; - int m_buffer_size; - int m_buffer_index; - float *m_buffer; // circular buffer -} t_prevl; - - -static void prevl_perform_float(t_prevl *x, t_float f) -{ - int index; - index=x->m_buffer_index+1; - index=(index==x->m_buffer_size)?0:index; - x->m_buffer_index=index; - x->m_buffer[index]=f; -} - -static void prevl_bang(t_prevl *x) -{ - int lo,hi,n,index,size; - t_atom *ap,*app; - float *buffer, *bp; - - lo=(int)x->m_lo; - hi=(int)x->m_hi; - - n=hi-lo; - size=x->m_buffer_size; - index=x->m_buffer_index; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - app=ap; - buffer=x->m_buffer; - bp=buffer+index-lo; - bp=(bp>=buffer)?bp:bp+size; // wrap - - if (bp-buffer>=n) - { // no wrap-around needed - index=n; - while(index--){ - SETFLOAT(app, *bp--); - app++; - } -// post("not wrapped, app-ap=%i",app-ap); - } - else // need to wrap - { - int ps, nn; - ps = bp-buffer; - nn=n; -// post(" nn=%i",nn); - for(;ps>=0;ps--) // don't we miss one sample in signal??? - { -// post("ps=%i",ps); - SETFLOAT(app, buffer[ps]); - app++; - nn--; - } - ps=size-1; -// post(" nn=%i",nn); - for(;nn>0;nn--) - { -// post("ps=%i",ps); - SETFLOAT(app, buffer[ps--]); - app++; - } - - } - - outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); - freebytes(ap, sizeof(t_atom)*n); -} - -static void prevl_clear(t_prevl *x) -{ - int i,s; - float *f; - f=x->m_buffer; - s=x->m_buffer_size; - for (i=0;isize) - { - post("prevl: higher bound cannot be higher than the buffer size..."); - hi=size; - } - if (lo<0) - { - post("prevl: lower bound cannot be negative..."); - lo=0; - } - if (hi<1) - { - post("prevl: higher bound cannot be smaller than one..."); - hi=1; - } - if (hi<=lo) - { - post("prevl: higher bound must be higher than lower bound..."); - lo=hi-1.0f; - } - - freebytes(x->m_buffer, x->m_buffer_size); - - x->m_hi=(float)((int)hi); - x->m_lo=(float)((int)lo); - x->m_buffer_size=(int)size; - x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); - prevl_clear(x); - x->m_buffer_index=0; -} - -static void *prevl_new(t_float lo, t_float hi, t_float size) -{ - t_prevl *x=(t_prevl *)pd_new(prevl_class); - outlet_new(&x->x_obj, gensym("list")); - x->m_buffer_size=0; - x->m_buffer=0; - prevl_set(x, lo, hi, size); - - floatinlet_new(&x->x_obj, &x->m_lo); - floatinlet_new(&x->x_obj, &x->m_hi); - - return (void *)x; -} - -static void prevl_free(t_prevl *x) -{ - freebytes(x->m_buffer, x->m_buffer_size); -} - -void prevl_setup(void) -{ - prevl_class = class_new(gensym("prevl"), - (t_newmethod)prevl_new, (t_method)prevl_free, - sizeof(t_prevl), - CLASS_DEFAULT, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); - - class_addmethod(prevl_class, (t_method)prevl_clear, gensym("clear"),0); - class_addfloat(prevl_class, (t_method)prevl_perform_float); - class_addbang(prevl_class, (t_method)prevl_bang); -} - diff --git a/source/threshold.c b/source/threshold.c deleted file mode 100644 index 2d99e03..0000000 --- a/source/threshold.c +++ /dev/null @@ -1,112 +0,0 @@ -/* --------------------- threshold ----------------------------- */ - -#include "defines.h" - -static t_class *threshold_class; - -typedef struct _threshold -{ - t_object x_obj; - t_outlet *x_outlet1; /* bang out for high thresh */ - t_outlet *x_outlet2; /* bang out for low thresh */ - t_clock *x_clock; /* wakeup for message output */ - int x_state; /* 1 = high, 0 = low */ - float x_hithresh; /* value of high threshold */ - float x_lothresh; /* value of low threshold */ - float x_deadwait; /* msec remaining in dead period */ - float x_hideadtime; /* hi dead */ - float x_lodeadtime; /* lo dead */ -} t_threshold; - -static void threshold_tick(t_threshold *x); -static void threshold_set(t_threshold *x, - t_floatarg hithresh, t_floatarg hideadtime, - t_floatarg lothresh, t_floatarg lodeadtime); - -static t_threshold *threshold_new(t_floatarg hithresh, - t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime) -{ - t_threshold *x = (t_threshold *) - pd_new(threshold_class); - x->x_state = 0; /* low state */ - x->x_deadwait = 0; /* no dead time */ - x->x_clock = clock_new(x, (t_method)threshold_tick); - x->x_outlet1 = outlet_new(&x->x_obj, gensym("bang")); - x->x_outlet2 = outlet_new(&x->x_obj, gensym("bang")); - threshold_set(x, hithresh, hideadtime, lothresh, lodeadtime); - return (x); -} - - /* "set" message to specify thresholds and dead times */ -static void threshold_set(t_threshold *x, - t_floatarg hithresh, t_floatarg hideadtime, - t_floatarg lothresh, t_floatarg lodeadtime) -{ - if (lothresh > hithresh) - lothresh = hithresh; - x->x_hithresh = hithresh; - x->x_hideadtime = hideadtime; - x->x_lothresh = lothresh; - x->x_lodeadtime = lodeadtime; -} - - /* number in inlet sets state -- note incompatible with JMAX which used - "int" message for this, impossible here because of auto signal conversion */ -static void threshold_ft1(t_threshold *x, t_floatarg f) -{ - x->x_state = (f != 0); - x->x_deadwait = 0; -} - -static void threshold_tick(t_threshold *x) -{ - if (x->x_state) - outlet_bang(x->x_outlet1); - else outlet_bang(x->x_outlet2); -} - -static void threshold_perform(t_threshold *x, t_float in) -{ - if (x->x_deadwait > 0) - x->x_deadwait -= 1; - else if (x->x_state) - { - /* we're high; look for low sample */ - if (in < x->x_lothresh) - { - clock_delay(x->x_clock, 0L); - x->x_state = 0; - x->x_deadwait = x->x_lodeadtime; - } - } - else - { - /* we're low; look for high sample */ - if (in >= x->x_hithresh) - { - clock_delay(x->x_clock, 0L); - x->x_state = 1; - x->x_deadwait = x->x_hideadtime; - } - } -} - - -static void threshold_ff(t_threshold *x) -{ - clock_free(x->x_clock); -} - -void threshold_setup( void) -{ - threshold_class = class_new(gensym("threshold"), - (t_newmethod)threshold_new, (t_method)threshold_ff, - sizeof(t_threshold), 0, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - - class_addfloat(threshold_class, (t_method)threshold_perform); - class_addmethod(threshold_class, (t_method)threshold_set, - gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(threshold_class, (t_method)threshold_ft1, - gensym("ft1"), A_FLOAT, 0); -} diff --git a/source/vabs.c b/source/vabs.c deleted file mode 100644 index c928c5e..0000000 --- a/source/vabs.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "defines.h" - -/*--------------- vabs ----------------*/ -/* absolute values of a list of floats */ - - -static t_class *vabs_class; - -typedef struct _vabs -{ - t_object x_obj; -} t_vabs; - - -static void vabs_perform(t_vabs *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - SETFLOAT(app, f>0?f:-f); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vabs_new() -{ - t_vabs *x=(t_vabs *)pd_new(vabs_class); - outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vabs_setup(void) -{ - vabs_class = class_new(gensym("vabs"), - (t_newmethod)vabs_new, 0, - sizeof(t_vabs), - CLASS_DEFAULT, - 0); - class_addlist(vabs_class, (t_method)vabs_perform); -} - diff --git a/source/vclip.c b/source/vclip.c deleted file mode 100644 index 4a11ef5..0000000 --- a/source/vclip.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "defines.h" - -/*--------------- vclip ----------------*/ -/* clips a vector */ - - -static t_class *vclip_class; - -typedef struct _vclip -{ - t_object x_obj; - float m_lo; - float m_hi; -} t_vclip; - - -static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - float lo,hi; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - lo=x->m_lo; - hi=x->m_hi; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - SETFLOAT(app, (fhi?hi:f))); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vclip_new(t_float lo, t_float hi) -{ - t_vclip *x=(t_vclip *)pd_new(vclip_class); - - floatinlet_new(&x->x_obj, &x->m_lo); - floatinlet_new(&x->x_obj, &x->m_hi); - - outlet_new(&x->x_obj, gensym("list")); - x->m_hi=hi; - x->m_lo=lo; - return (void *)x; -} - -void vclip_setup(void) -{ - vclip_class = class_new(gensym("vclip"), - (t_newmethod)vclip_new, 0, - sizeof(t_vclip), - CLASS_DEFAULT, - A_DEFFLOAT,A_DEFFLOAT,0); - class_addlist(vclip_class, (t_method)vclip_perform); -} - diff --git a/source/vcog.c b/source/vcog.c deleted file mode 100644 index 1dd68a4..0000000 --- a/source/vcog.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "defines.h" - -/*--------------- vcog ---------------*/ - -static t_class *vcog_class; - -typedef struct _vcog -{ - t_object x_obj; -} t_vcog; - - -static void vcog_perform(t_vcog *x, t_symbol *s, int argc, t_atom *argv) -{ - float sum=0.f; - float wsum=0.0f; - int i; - for (i = 0; i < argc; i++) - { - float tmp=atom_getfloat(&argv[i]); - sum+= tmp; - wsum+= tmp*i; - } - if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0f+(wsum/sum)); -} - -static void *vcog_new( t_float halfDecayTime) -{ - t_vcog *x=(t_vcog *)pd_new(vcog_class); - outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vcog_setup(void) -{ - vcog_class = class_new(gensym("vcog"), - (t_newmethod)vcog_new, 0, - sizeof(t_vcog), - CLASS_DEFAULT, - 0); - class_addlist(vcog_class, (t_method)vcog_perform); -} - diff --git a/source/vdbtorms.c b/source/vdbtorms.c deleted file mode 100644 index ab954f6..0000000 --- a/source/vdbtorms.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "defines.h" - -/*--------------- vdbtorms ----------------*/ - -static t_class *vdbtorms_class; - -typedef struct _vdbtorms -{ - t_object x_obj; -} t_vdbtorms; - -float dbtorms(float f) -{ - if (f <= 0) - return(0); - else - { - if (f > 485) - f = 485; - } - return (float)(exp((LOGTEN * 0.05) * (f-100.))); -} - -static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - - for (i = 0; i < argc; i++) - { - SETFLOAT(app, dbtorms(atom_getfloat(argv++))); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vdbtorms_new() -{ - t_vdbtorms *x=(t_vdbtorms *)pd_new(vdbtorms_class); - outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vdbtorms_setup(void) -{ - vdbtorms_class = class_new(gensym("vdbtorms"), - (t_newmethod)vdbtorms_new, 0, - sizeof(t_vdbtorms), - CLASS_DEFAULT, - 0); - class_addlist(vdbtorms_class, (t_method)vdbtorms_perform); -} - diff --git a/source/vdelta.c b/source/vdelta.c deleted file mode 100644 index cc809db..0000000 --- a/source/vdelta.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "defines.h" - -/*--------------- vdelta ----------------------------*/ -/* differences between element in succesive vectors */ - -static t_class *vdelta_class; - -typedef struct _vdelta -{ - t_object x_obj; - float m_c_leak; - float m_leak; - float *m_prev; - int m_n; -} t_vdelta; - - -static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; - m_leak=x->m_leak; - m_c_leak=x->m_c_leak; - - if (argc!=x->m_n) - { - int i; - if (x->m_prev) - freebytes(x->m_prev,x->m_n); - x->m_prev=(float*)getbytes(argc*sizeof(float)); - for(i=0;im_prev[i]=0.0f; - x->m_n=argc; - } - - fp=x->m_prev; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - SETFLOAT(app, f-*fp); - app++; - *fp++=f; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vdelta_new() -{ - t_vdelta *x=(t_vdelta *)pd_new(vdelta_class); - outlet_new(&x->x_obj, gensym("list")); - x->m_n=0; - x->m_prev=0; - return (void *)x; -} - -static void vdelta_free(t_vdelta *x) -{ - freebytes(x->m_prev,x->m_n); -} - -void vdelta_setup(void) -{ - vdelta_class = class_new(gensym("vdelta"), - (t_newmethod)vdelta_new, (t_method)vdelta_free, - sizeof(t_vdelta), - CLASS_DEFAULT, - 0); - class_addlist(vdelta_class, (t_method)vdelta_perform); -} diff --git a/source/vfmod.c b/source/vfmod.c deleted file mode 100644 index 7b7d1af..0000000 --- a/source/vfmod.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "defines.h" - -/*--------------- vfmod ----------------*/ -/* floating point modulo of a vector */ - - -static t_class *vfmod_class; - -typedef struct _vfmod -{ - t_object x_obj; - float m_y; -} t_vfmod; - - -static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - float y; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - y=x->m_y; - if (y==0.0f) - y=1.0f; - for (i = 0; i < argc; i++) - { - SETFLOAT(app, (float)fmod(atom_getfloat(argv++),y)); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vfmod_new(t_float y) -{ - t_vfmod *x=(t_vfmod *)pd_new(vfmod_class); - - floatinlet_new(&x->x_obj, &x->m_y); - - outlet_new(&x->x_obj, gensym("list")); - if (y==0.0f) - y=1.0f; - x->m_y=y; - return (void *)x; -} - -void vfmod_setup(void) -{ - vfmod_class = class_new(gensym("vfmod"), - (t_newmethod)vfmod_new, 0, - sizeof(t_vfmod), - CLASS_DEFAULT, - A_DEFFLOAT,A_DEFFLOAT,0); - class_addlist(vfmod_class, (t_method)vfmod_perform); -} - diff --git a/source/vftom.c b/source/vftom.c deleted file mode 100644 index 6355006..0000000 --- a/source/vftom.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "defines.h" - -/*--------------- vftom ----------------*/ - -static t_class *vftom_class; - -typedef struct _vftom -{ - t_object x_obj; -} t_vftom; - -float ftom(float f) -{ - return (float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); -} - -static void vftom_perform(t_vftom *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - - for (i = 0; i < argc; i++) - { - SETFLOAT(app, ftom(atom_getfloat(argv++))); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vftom_new() -{ - t_vftom *x=(t_vftom *)pd_new(vftom_class); - outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vftom_setup(void) -{ - vftom_class = class_new(gensym("vftom"), - (t_newmethod)vftom_new, 0, - sizeof(t_vftom), - CLASS_DEFAULT, - 0); - class_addlist(vftom_class, (t_method)vftom_perform); -} - diff --git a/source/vlavg.c b/source/vlavg.c deleted file mode 100644 index 1e6ba98..0000000 --- a/source/vlavg.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "defines.h" - -/*--------------- vlavg -----------------------*/ -/* leaky average of each element in a list */ -/* arguments: [halfdecay] */ - -static t_class *vlavg_class; - -typedef struct _vlavg -{ - t_object x_obj; - float m_c_leak; - float m_leak; - float *m_avg; - int m_n; -} t_vlavg; - - -static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; - m_leak=x->m_leak; - m_c_leak=x->m_c_leak; - - if (argc!=x->m_n) - { - int i; - if (x->m_avg) - freebytes(x->m_avg,x->m_n); - x->m_avg=(float*)getbytes(argc*sizeof(float)); - for(i=0;im_avg[i]=0.0f; - x->m_n=argc; - } - - fp=x->m_avg; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - *fp = *fp * m_c_leak + f * m_leak; - SETFLOAT(app, *fp); - app++; - fp++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void vlavg_setHalfDecay(t_vlavg *x, t_floatarg halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void *vlavg_new(t_float halfDecayTime) -{ - t_vlavg *x=(t_vlavg *)pd_new(vlavg_class); - outlet_new(&x->x_obj, gensym("list")); - vlavg_setHalfDecay(x, halfDecayTime); - x->m_n=0; - x->m_avg=0; - return (void *)x; -} - -static void vlavg_free(t_vlavg *x) -{ - freebytes(x->m_avg,x->m_n); -} - -void vlavg_setup(void) -{ - vlavg_class = class_new(gensym("vlavg"), - (t_newmethod)vlavg_new, (t_method)vlavg_free, - sizeof(t_vlavg), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addmethod(vlavg_class, (t_method)vlavg_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - class_addlist(vlavg_class, (t_method)vlavg_perform); -} diff --git a/source/vlmax.c b/source/vlmax.c deleted file mode 100644 index a566f49..0000000 --- a/source/vlmax.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "defines.h" - -/*--------------- vlmax -----------------------*/ -/* leaky maximum of each element in a list */ -/* arguments: [halfdecay] */ - -static t_class *vlmax_class; - -typedef struct _vlmax -{ - t_object x_obj; - float m_c_leak; - float m_leak; - float *m_max; - int m_n; -} t_vlmax; - - -static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; - m_leak=x->m_leak; - m_c_leak=x->m_c_leak; - - if (argc!=x->m_n) - { - int i; - if (x->m_max) - freebytes(x->m_max,x->m_n); - x->m_max=(float*)getbytes(argc*sizeof(float)); - for(i=0;im_max[i]=0.0f; - x->m_n=argc; - } - - fp=x->m_max; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - *fp =(f > *fp ) ? f : *fp *m_c_leak + f*m_leak; - SETFLOAT(app, *fp); - app++; - fp++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void vlmax_setHalfDecay(t_vlmax *x, t_floatarg halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void *vlmax_new(t_float halfDecayTime) -{ - t_vlmax *x=(t_vlmax *)pd_new(vlmax_class); - outlet_new(&x->x_obj, gensym("list")); - vlmax_setHalfDecay(x, halfDecayTime); - x->m_n=0; - x->m_max=0; - return (void *)x; -} - -static void vlmax_free(t_vlmax *x) -{ - freebytes(x->m_max,x->m_n); -} - -void vlmax_setup(void) -{ - vlmax_class = class_new(gensym("vlmax"), - (t_newmethod)vlmax_new, (t_method)vlmax_free, - sizeof(t_vlmax), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addmethod(vlmax_class, (t_method)vlmax_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - class_addlist(vlmax_class, (t_method)vlmax_perform); -} diff --git a/source/vlmin.c b/source/vlmin.c deleted file mode 100644 index b839826..0000000 --- a/source/vlmin.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "defines.h" - -/*--------------- vlmin -----------------------*/ -/* leaky minimum of each element in a list */ -/* arguments: [halfdecay] */ - -static t_class *vlmin_class; - -typedef struct _vlmin -{ - t_object x_obj; - float m_c_leak; - float m_leak; - float *m_min; - int m_n; -} t_vlmin; - - -static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - float *fp; - float m_leak; - float m_c_leak; - m_leak=x->m_leak; - m_c_leak=x->m_c_leak; - - if (argc!=x->m_n) - { - int i; - if (x->m_min) - freebytes(x->m_min,x->m_n); - x->m_min=(float*)getbytes(argc*sizeof(float)); - for(i=0;im_min[i]=0.0f; - x->m_n=argc; - } - - fp=x->m_min; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - *fp =(f < *fp ) ? f : *fp *m_c_leak + f*m_leak; - SETFLOAT(app, *fp); - app++; - fp++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void vlmin_setHalfDecay(t_vlmin *x, t_floatarg halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void *vlmin_new(t_float halfDecayTime) -{ - t_vlmin *x=(t_vlmin *)pd_new(vlmin_class); - outlet_new(&x->x_obj, gensym("list")); - vlmin_setHalfDecay(x, halfDecayTime); - x->m_n=0; - x->m_min=0; - return (void *)x; -} - -static void vlmin_free(t_vlmin *x) -{ - freebytes(x->m_min,x->m_n); -} - -void vlmin_setup(void) -{ - vlmin_class = class_new(gensym("vlmin"), - (t_newmethod)vlmin_new, (t_method)vlmin_free, - sizeof(t_vlmin), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addmethod(vlmin_class, (t_method)vlmin_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - class_addlist(vlmin_class, (t_method)vlmin_perform); -} diff --git a/source/vlrange.c b/source/vlrange.c deleted file mode 100644 index 07b383f..0000000 --- a/source/vlrange.c +++ /dev/null @@ -1,99 +0,0 @@ -#include "defines.h" - -/*--------------- vlrange -----------------------*/ -/* leaky range of each element in a list */ -/* arguments: [halfdecay] */ - -static t_class *vlrange_class; - -typedef struct _vlrange -{ - t_object x_obj; - float m_c_leak; - float m_leak; - float *m_min; - float *m_max; - int m_n; -} t_vlrange; - - -static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - float *fmin, *fmax; - float m_leak; - float m_c_leak; - m_leak=x->m_leak; - m_c_leak=x->m_c_leak; - - if (argc!=x->m_n) - { - int i; - if (x->m_min) - { - freebytes(x->m_min,x->m_n); - freebytes(x->m_max,x->m_n); - } - x->m_min=(float*)getbytes(argc*sizeof(float)); - x->m_max=(float*)getbytes(argc*sizeof(float)); - for(i=0;im_min[i]=0.0f; - x->m_max[i]=0.0f; - } - x->m_n=argc; - } - - fmin=x->m_min; - fmax=x->m_max; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(argv++); - *fmax =(f > *fmax ) ? f : *fmax *m_c_leak + f*m_leak; - *fmin =(f < *fmin ) ? f : *fmin *m_c_leak + f*m_leak; - SETFLOAT(app, *fmax-*fmin); - app++; - fmax++; - fmin++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void vlrange_setHalfDecay(t_vlrange *x, t_floatarg halfDecayTime) -{ - x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); - x->m_leak=1.0f-x->m_c_leak; -} - -static void *vlrange_new(t_float halfDecayTime) -{ - t_vlrange *x=(t_vlrange *)pd_new(vlrange_class); - outlet_new(&x->x_obj, gensym("list")); - vlrange_setHalfDecay(x, halfDecayTime); - x->m_n=0; - x->m_min=0; - x->m_max=0; - return (void *)x; -} - -static void vlrange_free(t_vlrange *x) -{ - freebytes(x->m_max,x->m_n); - freebytes(x->m_min,x->m_n); -} - -void vlrange_setup(void) -{ - vlrange_class = class_new(gensym("vlrange"), - (t_newmethod)vlrange_new, (t_method)vlrange_free, - sizeof(t_vlrange), - CLASS_DEFAULT, - A_DEFFLOAT, 0); - class_addmethod(vlrange_class, (t_method)vlrange_setHalfDecay, - gensym("decay"), A_DEFFLOAT, NULL); - class_addlist(vlrange_class, (t_method)vlrange_perform); -} diff --git a/source/vmax.c b/source/vmax.c deleted file mode 100644 index ac56423..0000000 --- a/source/vmax.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "defines.h" - -/*--------------- vmax ---------------*/ -/* maximum value in a list of float - and its location (index) -*/ - -static t_class *vmax_class; - -typedef struct _vmax -{ - t_object x_obj; - t_outlet *m_out_maxi; -} t_vmax; - - -static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - int maxi; - float max=-MAXFLOAT; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(&argv[i]); - if (f>max) - { - max=f; - maxi=i; - } - } - outlet_float(x->x_obj.ob_outlet, max); - outlet_float(x->m_out_maxi, (float)(maxi+1)); -} - -static void *vmax_new( t_float halfDecayTime) -{ - t_vmax *x=(t_vmax *)pd_new(vmax_class); - outlet_new(&x->x_obj, gensym("float")); - x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vmax_setup(void) -{ - vmax_class = class_new(gensym("vmax"), - (t_newmethod)vmax_new, 0, - sizeof(t_vmax), - CLASS_DEFAULT, - 0); - class_addlist(vmax_class, (t_method)vmax_perform); -} - diff --git a/source/vmin.c b/source/vmin.c deleted file mode 100644 index a0b578e..0000000 --- a/source/vmin.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "defines.h" - -/*--------------- vmin ---------------*/ -/* maximum value in a list of float - and its location (index) -*/ - -static t_class *vmin_class; - -typedef struct _vmin -{ - t_object x_obj; - t_outlet *m_out_maxi; -} t_vmin; - - -static void vmin_perform(t_vmin *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - int mini; - float min=MAXFLOAT; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(&argv[i]); - if (fx_obj.ob_outlet, min); - outlet_float(x->m_out_maxi, (float)(mini+1)); -} - -static void *vmin_new( t_float halfDecayTime) -{ - t_vmin *x=(t_vmin *)pd_new(vmin_class); - outlet_new(&x->x_obj, gensym("float")); - x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vmin_setup(void) -{ - vmin_class = class_new(gensym("vmin"), - (t_newmethod)vmin_new, 0, - sizeof(t_vmin), - CLASS_DEFAULT, - 0); - class_addlist(vmin_class, (t_method)vmin_perform); -} - diff --git a/source/vmtof.c b/source/vmtof.c deleted file mode 100644 index 828dcb6..0000000 --- a/source/vmtof.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "defines.h" - -/*--------------- vmtof ----------------*/ - -static t_class *vmtof_class; - -typedef struct _vmtof -{ - t_object x_obj; -} t_vmtof; - -float mtof(float f) -{ - if (f <= -1500) return(0); - else if (f > 1499) return(mtof(1499)); - else return (float)(8.17579891564 * exp(.0577622650 * f)); -} - -static void vmtof_perform(t_vmtof *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - - for (i = 0; i < argc; i++) - { - SETFLOAT(app, mtof(atom_getfloat(argv++))); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vmtof_new() -{ - t_vmtof *x=(t_vmtof *)pd_new(vmtof_class); - outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vmtof_setup(void) -{ - vmtof_class = class_new(gensym("vmtof"), - (t_newmethod)vmtof_new, 0, - sizeof(t_vmtof), - CLASS_DEFAULT, - 0); - class_addlist(vmtof_class, (t_method)vmtof_perform); -} - diff --git a/source/vnmax.c b/source/vnmax.c deleted file mode 100644 index 7003f6d..0000000 --- a/source/vnmax.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "defines.h" - -/*--------------- vnmax ---------------*/ -/* maximum n values in a list of float - and their locations (indices) -*/ - -//// UNCOMPLETE - - -static t_class *vnmax_class; - -typedef struct _vnmax -{ - t_object x_obj; - t_outlet *m_out_maxi; -} t_vnmax; - - -static void vnmax_perform(t_vnmax *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - int maxi; - float max=-MAXFLOAT; - for (i = 0; i < argc; i++) - { - float f=atom_getfloat(&argv[i]); - if (f>max) - { - max=f; - maxi=i; - } - } - outlet_float(x->x_obj.ob_outlet, max); - outlet_float(x->m_out_maxi, (float)(maxi+1)); -} - -static void *vnmax_new( t_float halfDecayTime) -{ - t_vnmax *x=(t_vnmax *)pd_new(vnmax_class); - outlet_new(&x->x_obj, gensym("list")); - x->m_out_maxi=outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vnmax_setup(void) -{ - vnmax_class = class_new(gensym("vnmax"), - (t_newmethod)vnmax_new, 0, - sizeof(t_vnmax), - CLASS_DEFAULT, - 0); - class_addlist(vnmax_class, (t_method)vnmax_perform); -} - diff --git a/source/vpow.c b/source/vpow.c deleted file mode 100644 index 6859859..0000000 --- a/source/vpow.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "defines.h" - -/*--------------- vpow ----------------*/ - -static t_class *vpow_class; - -typedef struct _vpow -{ - t_object x_obj; - float m_y; -} t_vpow; - - -static void vpow_perform(t_vpow *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - float y; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - y=x->m_y; - if (y==0.0f) - y=1.0f; - for (i = 0; i < argc; i++) - { - float x=atom_getfloat(argv++); - if (x>0) - x=(float)powf(x,y); - else - x=-1000.; - SETFLOAT(app, x); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vpow_new(t_float y) -{ - t_vpow *x=(t_vpow *)pd_new(vpow_class); - - floatinlet_new(&x->x_obj, &x->m_y); - - outlet_new(&x->x_obj, gensym("list")); - if (y==0.0f) - y=1.0f; - x->m_y=y; - return (void *)x; -} - -void vpow_setup(void) -{ - vpow_class = class_new(gensym("vpow"), - (t_newmethod)vpow_new, 0, - sizeof(t_vpow), - CLASS_DEFAULT, - A_DEFFLOAT,A_DEFFLOAT,0); - class_addlist(vpow_class, (t_method)vpow_perform); -} - diff --git a/source/vrms.c b/source/vrms.c deleted file mode 100644 index 52b8d6d..0000000 --- a/source/vrms.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "defines.h" - -/*--------------- vrms ---------------*/ - -static t_class *vrms_class; - -typedef struct _vrms -{ - t_object x_obj; -} t_vrms; - - -static void vrms_perform(t_vrms *x, t_symbol *s, int argc, t_atom *argv) -{ - float sum=0.f; - int i; - for (i = 0; i < argc; i++) - { - float tmp=atom_getfloat(&argv[i]); - sum+= tmp*tmp; - } - outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sum/argc)); -} - -static void *vrms_new( t_float halfDecayTime) -{ - t_vrms *x=(t_vrms *)pd_new(vrms_class); - outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vrms_setup(void) -{ - vrms_class = class_new(gensym("vrms"), - (t_newmethod)vrms_new, 0, - sizeof(t_vrms), - CLASS_DEFAULT, - 0); - class_addlist(vrms_class, (t_method)vrms_perform); -} - diff --git a/source/vrmstodb.c b/source/vrmstodb.c deleted file mode 100644 index d375bf9..0000000 --- a/source/vrmstodb.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "defines.h" - -/*--------------- vrmstodb ----------------*/ - -static t_class *vrmstodb_class; - -typedef struct _vrmstodb -{ - t_object x_obj; -} t_vrmstodb; - -float rmstodb(float f) -{ - if (f <= 0) return (0); - else - { - float val = (float)(100 + 20./LOGTEN * log(f)); - return (val < 0 ? 0 : val); - } -} - -static void vrmstodb_perform(t_vrmstodb *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_atom *ap,*app; - ap = (t_atom *)getbytes(sizeof(t_atom)*argc); - app=ap; - - for (i = 0; i < argc; i++) - { - SETFLOAT(app, rmstodb(atom_getfloat(argv++))); - app++; - } - outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); - freebytes(ap,argc); -} - -static void *vrmstodb_new() -{ - t_vrmstodb *x=(t_vrmstodb *)pd_new(vrmstodb_class); - outlet_new(&x->x_obj, gensym("list")); - return (void *)x; -} - -void vrmstodb_setup(void) -{ - vrmstodb_class = class_new(gensym("vrmstodb"), - (t_newmethod)vrmstodb_new, 0, - sizeof(t_vrmstodb), - CLASS_DEFAULT, - 0); - class_addlist(vrmstodb_class, (t_method)vrmstodb_perform); -} - diff --git a/source/vstd.c b/source/vstd.c deleted file mode 100644 index 538cb94..0000000 --- a/source/vstd.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "defines.h" - -/*--------------- vstd ---------------*/ - -static t_class *vstd_class; - -typedef struct _vstd -{ - t_object x_obj; -} t_vstd; - - -static void vstd_perform(t_vstd *x, t_symbol *s, int argc, t_atom *argv) -{ - float sumsq=0.0f; - float sum=0.0f; - int i; - for (i = 0; i < argc; i++) - { - float tmp=atom_getfloat(&argv[i]); - sumsq+= tmp*tmp; - sum+=tmp; - } - sumsq/=argc; - sum/=argc; - outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sumsq-sum*sum)); -} - -static void *vstd_new( t_float halfDecayTime) -{ - t_vstd *x=(t_vstd *)pd_new(vstd_class); - outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vstd_setup(void) -{ - vstd_class = class_new(gensym("vstd"), - (t_newmethod)vstd_new, 0, - sizeof(t_vstd), - CLASS_DEFAULT, - 0); - class_addlist(vstd_class, (t_method)vstd_perform); -} - diff --git a/source/vsum.c b/source/vsum.c deleted file mode 100644 index dd49f4c..0000000 --- a/source/vsum.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "defines.h" - -/*--------------- vsum ---------------*/ - -static t_class *vsum_class; - -typedef struct _vsum -{ - t_object x_obj; -} t_vsum; - - -static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv) -{ - float sum=0.f; - int i; - for (i = 0; i < argc; i++) - { - sum+= atom_getfloat(&argv[i]); - } - outlet_float(x->x_obj.ob_outlet, sum); -} - -static void *vsum_new() -{ - t_vsum *x=(t_vsum *)pd_new(vsum_class); - outlet_new(&x->x_obj, gensym("float")); - return (void *)x; -} - -void vsum_setup(void) -{ - vsum_class = class_new(gensym("vsum"), - (t_newmethod)vsum_new, 0, - sizeof(t_vsum), - CLASS_DEFAULT, - 0); - class_addlist(vsum_class, (t_method)vsum_perform); -} - diff --git a/source/vthreshold.c b/source/vthreshold.c deleted file mode 100644 index 106cf72..0000000 --- a/source/vthreshold.c +++ /dev/null @@ -1,106 +0,0 @@ -/* --------------------- vthreshold ----------------------------- */ - -#include "defines.h" -#include "memory.h" - -static t_class *vthreshold_class; - -typedef struct _vthreshold -{ - t_object x_obj; - t_outlet *x_outlet1; /* bang out for high thresh */ - t_outlet *x_outlet2; /* bang out for low thresh */ - int *x_state; /* 1 = high, 0 = low */ - int x_n; - float x_hithresh; /* value of high vthreshold */ - float x_lothresh; /* value of low vthreshold */ - float x_hideadtime; /* hi dead */ - float x_lodeadtime; /* lo dead */ -} t_vthreshold; - - /* "set" message to specify vthresholds and dead times */ -static void vthreshold_set(t_vthreshold *x, - t_floatarg hithresh, t_floatarg hideadtime, - t_floatarg lothresh, t_floatarg lodeadtime, - t_floatarg nf) -{ - if (lothresh > hithresh) - lothresh = hithresh; - x->x_hithresh = hithresh; - x->x_hideadtime = hideadtime; - x->x_lothresh = lothresh; - x->x_lodeadtime = lodeadtime; - freebytes(x->x_state,x->x_n); - x->x_n=(int)nf; - x->x_state = (int *)getbytes(sizeof(int)*x->x_n); - memset(x->x_state , 0, x->x_n); -} - -static t_vthreshold *vthreshold_new(t_floatarg hithresh, - t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime, t_floatarg n) -{ - t_vthreshold *x = (t_vthreshold *) - pd_new(vthreshold_class); - x->x_state = 0; /* low state */ - x->x_outlet1 = outlet_new(&x->x_obj, gensym("float")); - x->x_outlet2 = outlet_new(&x->x_obj, gensym("float")); - vthreshold_set(x, hithresh, hideadtime, lothresh, lodeadtime, n); - return (x); -} - -static void vthreshold_free(t_vthreshold *x) -{ - freebytes(x->x_state,x->x_n); -} - -static void vthreshold_perform(t_vthreshold *x, t_symbol *s, int argc, t_atom *argv) -{ - int i; - int *state; - - state=x->x_state; - if (argc>x->x_n) argc=x->x_n; - for (i=0;ix->x_hithresh) - { - outlet_float(x->x_outlet1, (float)i); // on - *state=1; - } - } - else - { - if (fx_lothresh) - { - outlet_float(x->x_outlet2, (float)i); // off - *state=-1; - } - } - state++; - } -} - - -static void vthreshold_ff(t_vthreshold *x) -{ - freebytes(x->x_state,x->x_n); -} - -void vthreshold_setup( void) -{ - vthreshold_class = class_new(gensym("vthreshold"), - (t_newmethod)vthreshold_new, (t_method)vthreshold_free, - sizeof(t_vthreshold), 0, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - - class_addlist(vthreshold_class, (t_method)vthreshold_perform); - class_addmethod(vthreshold_class, (t_method)vthreshold_set, - gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); -// class_addmethod(vthreshold_class, (t_method)vthreshold_ft1, -// gensym("ft1"), A_FLOAT, 0); -} diff --git a/source/vvconv.c b/source/vvconv.c deleted file mode 100644 index 5541705..0000000 --- a/source/vvconv.c +++ /dev/null @@ -1,151 +0,0 @@ -#include "defines.h" - -/*--------------- vvconv ---------------*/ -/* vector convolution -*/ - -static t_class *vvconv_class; -static t_class *vvconv_scal_class; - -typedef struct _vvconv -{ - t_object x_obj; - - t_int n1, n2; - - t_float *buf1, *buf2; - - t_float f; -} t_vvconv; - - -static void vvconv_lst2(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - if (x->n2 != argc) { - freebytes(x->buf2, x->n2 * sizeof(t_float)); - x->n2 = argc; - x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); - }; - fp = x->buf2; - while(argc--)*fp++=atom_getfloat(argv++); -} - -static void vvconv_lst(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - t_atom *ap; - int n; - - if (argc){ - if (x->n1 != argc) { - freebytes(x->buf1, x->n1 * sizeof(t_float)); - x->n1 = argc; - x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); - }; - fp = x->buf1; - while(argc--)*fp++=atom_getfloat(argv++); - } - - if (x->n1*x->n2==1){ - outlet_float(x->x_obj.ob_outlet, *x->buf1**x->buf2); - return; - } - if (x->n1==1){ - t_atom *a; - int i = x->n2; - t_float f = *x->buf1; - fp = x->buf2; - n = x->n2; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - while(i--){ - SETFLOAT(a, *fp++*f); - a++; - } - } else if (x->n2==1){ - t_float f = *x->buf2; - t_atom *a; - int i = x->n1; - n = x->n1; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - fp = x->buf1; - while(i--){ - SETFLOAT(a, *fp++*f); - a++; - } - } else { - t_atom *a; - int i,j,n1,n2; - t_float *f; - t_float *g; - t_float *fp2=x->buf2; - fp = x->buf1; - n1=x->n1; - n2=x->n2; - n = n1 + n2 - 1; - f = (t_float *)getbytes(sizeof(t_float)*n); - g=f; - for(i=0;ix_obj.ob_outlet, gensym("list"), n, ap); - freebytes(ap, sizeof(t_atom)*n); -} -static void vvconv_free(t_vvconv *x) -{ - freebytes(x->buf1, sizeof(t_float)*x->n1); - freebytes(x->buf2, sizeof(t_float)*x->n2); -} - -static void *vvconv_new(t_symbol *s, int argc, t_atom *argv) -{ - t_vvconv *x; - - if (argc-1){ - x = (t_vvconv *)pd_new(vvconv_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); - } else x = (t_vvconv *)pd_new(vvconv_scal_class); - - outlet_new(&x->x_obj, 0); - - x->n1 =1; - x->buf1 =(t_float*)getbytes(sizeof(t_float)); - *x->buf1=0; - - if (argc)vvconv_lst2(x, gensym("list"), argc, argv); - else { - x->n2 =1; - x->buf2 =(t_float*)getbytes(sizeof(t_float)); - *x->buf2=0; - } - - if (argc==1)floatinlet_new(&x->x_obj, x->buf2); - - return (x); -} - -void vvconv_setup(void) -{ - vvconv_class = class_new(gensym("vvconv"), (t_newmethod)vvconv_new, - (t_method)vvconv_free, sizeof(t_vvconv), 0, A_GIMME, 0); - class_addlist(vvconv_class, vvconv_lst); - class_addmethod (vvconv_class, (t_method)vvconv_lst2, gensym(""), A_GIMME, 0); - vvconv_scal_class = class_new(gensym("vv+"), 0, (t_method)vvconv_free, - sizeof(t_vvconv), 0, 0); - class_addlist(vvconv_scal_class, vvconv_lst); -} diff --git a/source/vvminus.c b/source/vvminus.c deleted file mode 100644 index b8b7246..0000000 --- a/source/vvminus.c +++ /dev/null @@ -1,142 +0,0 @@ -#include "defines.h" - -/*--------------- vvminus ---------------*/ -/* vector substraction -*/ - -static t_class *vvminus_class; -static t_class *vvminus_scal_class; - -typedef struct _vvminus -{ - t_object x_obj; - - t_int n1, n2; - - t_float *buf1, *buf2; - - t_float f; -} t_vvminus; - - -static void vvminus_lst2(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - if (x->n2 != argc) { - freebytes(x->buf2, x->n2 * sizeof(t_float)); - x->n2 = argc; - x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); - }; - fp = x->buf2; - while(argc--)*fp++=atom_getfloat(argv++); -} - -static void vvminus_lst(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - t_atom *ap; - int n; - - if (argc){ - if (x->n1 != argc) { - freebytes(x->buf1, x->n1 * sizeof(t_float)); - x->n1 = argc; - x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); - }; - fp = x->buf1; - while(argc--)*fp++=atom_getfloat(argv++); - } - - if (x->n1*x->n2==1){ - outlet_float(x->x_obj.ob_outlet, *x->buf1-*x->buf2); - return; - } - if (x->n1==1){ - t_atom *a; - int i = x->n2; - t_float f = *x->buf1; - fp = x->buf2; - n = x->n2; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - while(i--){ - SETFLOAT(a, f-*fp++); - a++; - } - } else if (x->n2==1){ - t_float f = *x->buf2; - t_atom *a; - int i = x->n1; - n = x->n1; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - fp = x->buf1; - while(i--){ - SETFLOAT(a, *fp++-f); - a++; - } - } else { - t_atom *a; - int i; - t_float *fp2=x->buf2; - fp = x->buf1; - n = x->n1; - if (x->n1!=x->n2){ - post("scalar multiplication: truncating vectors to the same length"); - if (x->n2n1)n=x->n2; - } - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - i=n; - while(i--){ - SETFLOAT(a, *fp++-*fp2++); - a++; - } - } - outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); - freebytes(ap, sizeof(t_atom)*n); -} -static void vvminus_free(t_vvminus *x) -{ - freebytes(x->buf1, sizeof(t_float)*x->n1); - freebytes(x->buf2, sizeof(t_float)*x->n2); -} - -static void *vvminus_new(t_symbol *s, int argc, t_atom *argv) -{ - t_vvminus *x; - - if (argc-1){ - x = (t_vvminus *)pd_new(vvminus_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); - } else x = (t_vvminus *)pd_new(vvminus_scal_class); - - outlet_new(&x->x_obj, 0); - - x->n1 =1; - x->buf1 =(t_float*)getbytes(sizeof(t_float)); - *x->buf1=0; - - if (argc)vvminus_lst2(x, gensym("list"), argc, argv); - else { - x->n2 =1; - x->buf2 =(t_float*)getbytes(sizeof(t_float)); - *x->buf2=0; - } - - if (argc==1)floatinlet_new(&x->x_obj, x->buf2); - - return (x); -} - -void vvminus_setup(void) -{ - vvminus_class = class_new(gensym("vvminus"), (t_newmethod)vvminus_new, - (t_method)vvminus_free, sizeof(t_vvminus), 0, A_GIMME, 0); - class_addcreator((t_newmethod)vvplus_new, gensym("vv-"), A_GIMME, 0); - class_addlist(vvminus_class, vvminus_lst); - class_addmethod (vvminus_class, (t_method)vvminus_lst2, gensym(""), A_GIMME, 0); - vvminus_scal_class = class_new(gensym("vv-"), 0, (t_method)vvminus_free, - sizeof(t_vvminus), 0, 0); - class_addlist(vvminus_scal_class, vvminus_lst); -} diff --git a/source/vvplus.c b/source/vvplus.c deleted file mode 100644 index a49ce39..0000000 --- a/source/vvplus.c +++ /dev/null @@ -1,142 +0,0 @@ -#include "defines.h" - -/*--------------- vvplus ---------------*/ -/* vector addition -*/ - -static t_class *vvplus_class; -static t_class *vvplus_scal_class; - -typedef struct _vvplus -{ - t_object x_obj; - - t_int n1, n2; - - t_float *buf1, *buf2; - - t_float f; -} t_vvplus; - - -static void vvplus_lst2(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - if (x->n2 != argc) { - freebytes(x->buf2, x->n2 * sizeof(t_float)); - x->n2 = argc; - x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); - }; - fp = x->buf2; - while(argc--)*fp++=atom_getfloat(argv++); -} - -static void vvplus_lst(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) -{ - t_float *fp; - t_atom *ap; - int n; - - if (argc){ - if (x->n1 != argc) { - freebytes(x->buf1, x->n1 * sizeof(t_float)); - x->n1 = argc; - x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); - }; - fp = x->buf1; - while(argc--)*fp++=atom_getfloat(argv++); - } - - if (x->n1*x->n2==1){ - outlet_float(x->x_obj.ob_outlet, *x->buf1+*x->buf2); - return; - } - if (x->n1==1){ - t_atom *a; - int i = x->n2; - t_float f = *x->buf1; - fp = x->buf2; - n = x->n2; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - while(i--){ - SETFLOAT(a, *fp+++f); - a++; - } - } else if (x->n2==1){ - t_float f = *x->buf2; - t_atom *a; - int i = x->n1; - n = x->n1; - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - fp = x->buf1; - while(i--){ - SETFLOAT(a, *fp+++f); - a++; - } - } else { - t_atom *a; - int i; - t_float *fp2=x->buf2; - fp = x->buf1; - n = x->n1; - if (x->n1!=x->n2){ - post("scalar multiplication: truncating vectors to the same length"); - if (x->n2n1)n=x->n2; - } - ap = (t_atom *)getbytes(sizeof(t_atom)*n); - a = ap; - i=n; - while(i--){ - SETFLOAT(a, *fp+++*fp2++); - a++; - } - } - outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); - freebytes(ap, sizeof(t_atom)*n); -} -static void vvplus_free(t_vvplus *x) -{ - freebytes(x->buf1, sizeof(t_float)*x->n1); - freebytes(x->buf2, sizeof(t_float)*x->n2); -} - -static void *vvplus_new(t_symbol *s, int argc, t_atom *argv) -{ - t_vvplus *x; - - if (argc-1){ - x = (t_vvplus *)pd_new(vvplus_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); - } else x = (t_vvplus *)pd_new(vvplus_scal_class); - - outlet_new(&x->x_obj, 0); - - x->n1 =1; - x->buf1 =(t_float*)getbytes(sizeof(t_float)); - *x->buf1=0; - - if (argc)vvplus_lst2(x, gensym("list"), argc, argv); - else { - x->n2 =1; - x->buf2 =(t_float*)getbytes(sizeof(t_float)); - *x->buf2=0; - } - - if (argc==1)floatinlet_new(&x->x_obj, x->buf2); - - return (x); -} - -void vvplus_setup(void) -{ - vvplus_class = class_new(gensym("vvplus"), (t_newmethod)vvplus_new, - (t_method)vvplus_free, sizeof(t_vvplus), 0, A_GIMME, 0); - class_addcreator((t_newmethod)vvplus_new, gensym("vv+"), A_GIMME, 0); - class_addlist(vvplus_class, vvplus_lst); - class_addmethod (vvplus_class, (t_method)vvplus_lst2, gensym(""), A_GIMME, 0); - vvplus_scal_class = class_new(gensym("vv+"), 0, (t_method)vvplus_free, - sizeof(t_vvplus), 0, 0); - class_addlist(vvplus_scal_class, vvplus_lst); -} diff --git a/threshold-help.pd b/threshold-help.pd new file mode 100644 index 0000000..07f27c6 --- /dev/null +++ b/threshold-help.pd @@ -0,0 +1,50 @@ +#N canvas 114 43 708 422 10; +#X text 221 309 Arguments:; +#X text 310 310 1 trigger threshold; +#X floatatom 20 235 5 0 0; +#X obj 42 363 print trigger; +#X obj 183 363 print rest; +#X text 310 341 3 rest threshold; +#X msg 172 268 1; +#X msg 208 268 0; +#X text 249 209 "set" to change the parameters; +#X text 245 263 zero or nonszero in inlet to set the state to "high" +or "low". There is no debounce period after this.; +#X text 208 12 - TRIGGER FROM FLOAT STREAM; +#X obj 124 11 threshold; +#X text 26 48 threshold monitors its input float stream and outputs +bangs when the signal exceeds a specified "trigger" value \, and also +when the input value recedes below a "rest" value. You can specify +debounce in number of floats received \, for the threshold~ to wait +after the two event types before triggering again.; +#X text 310 326 2 trigger debounce number; +#X text 309 358 4 rest debounce number; +#X obj 20 212 float; +#X obj 20 189 metro 100; +#X obj 20 148 loadbang; +#X obj 20 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 132 171 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 1200 1; +#X msg 129 208 set 50 0 10 0; +#X msg 130 231 set 50 15 10 15; +#X text 12 393 see also threshold~; +#X obj 164 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 20 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 20 332 threshold 70 10 30 10; +#X text 620 398 j#|@2002; +#X obj 638 376 SMLib-help; +#X connect 2 0 25 0; +#X connect 15 0 2 0; +#X connect 16 0 15 0; +#X connect 17 0 18 0; +#X connect 18 0 16 0; +#X connect 19 0 15 1; +#X connect 20 0 25 0; +#X connect 21 0 25 0; +#X connect 25 0 3 0; +#X connect 25 0 24 0; +#X connect 25 1 4 0; +#X connect 25 1 23 0; diff --git a/threshold.c b/threshold.c new file mode 100644 index 0000000..2d99e03 --- /dev/null +++ b/threshold.c @@ -0,0 +1,112 @@ +/* --------------------- threshold ----------------------------- */ + +#include "defines.h" + +static t_class *threshold_class; + +typedef struct _threshold +{ + t_object x_obj; + t_outlet *x_outlet1; /* bang out for high thresh */ + t_outlet *x_outlet2; /* bang out for low thresh */ + t_clock *x_clock; /* wakeup for message output */ + int x_state; /* 1 = high, 0 = low */ + float x_hithresh; /* value of high threshold */ + float x_lothresh; /* value of low threshold */ + float x_deadwait; /* msec remaining in dead period */ + float x_hideadtime; /* hi dead */ + float x_lodeadtime; /* lo dead */ +} t_threshold; + +static void threshold_tick(t_threshold *x); +static void threshold_set(t_threshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime); + +static t_threshold *threshold_new(t_floatarg hithresh, + t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime) +{ + t_threshold *x = (t_threshold *) + pd_new(threshold_class); + x->x_state = 0; /* low state */ + x->x_deadwait = 0; /* no dead time */ + x->x_clock = clock_new(x, (t_method)threshold_tick); + x->x_outlet1 = outlet_new(&x->x_obj, gensym("bang")); + x->x_outlet2 = outlet_new(&x->x_obj, gensym("bang")); + threshold_set(x, hithresh, hideadtime, lothresh, lodeadtime); + return (x); +} + + /* "set" message to specify thresholds and dead times */ +static void threshold_set(t_threshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime) +{ + if (lothresh > hithresh) + lothresh = hithresh; + x->x_hithresh = hithresh; + x->x_hideadtime = hideadtime; + x->x_lothresh = lothresh; + x->x_lodeadtime = lodeadtime; +} + + /* number in inlet sets state -- note incompatible with JMAX which used + "int" message for this, impossible here because of auto signal conversion */ +static void threshold_ft1(t_threshold *x, t_floatarg f) +{ + x->x_state = (f != 0); + x->x_deadwait = 0; +} + +static void threshold_tick(t_threshold *x) +{ + if (x->x_state) + outlet_bang(x->x_outlet1); + else outlet_bang(x->x_outlet2); +} + +static void threshold_perform(t_threshold *x, t_float in) +{ + if (x->x_deadwait > 0) + x->x_deadwait -= 1; + else if (x->x_state) + { + /* we're high; look for low sample */ + if (in < x->x_lothresh) + { + clock_delay(x->x_clock, 0L); + x->x_state = 0; + x->x_deadwait = x->x_lodeadtime; + } + } + else + { + /* we're low; look for high sample */ + if (in >= x->x_hithresh) + { + clock_delay(x->x_clock, 0L); + x->x_state = 1; + x->x_deadwait = x->x_hideadtime; + } + } +} + + +static void threshold_ff(t_threshold *x) +{ + clock_free(x->x_clock); +} + +void threshold_setup( void) +{ + threshold_class = class_new(gensym("threshold"), + (t_newmethod)threshold_new, (t_method)threshold_ff, + sizeof(t_threshold), 0, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + + class_addfloat(threshold_class, (t_method)threshold_perform); + class_addmethod(threshold_class, (t_method)threshold_set, + gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(threshold_class, (t_method)threshold_ft1, + gensym("ft1"), A_FLOAT, 0); +} diff --git a/vabs-help.pd b/vabs-help.pd new file mode 100644 index 0000000..79914c7 --- /dev/null +++ b/vabs-help.pd @@ -0,0 +1,6 @@ +#N canvas 490 308 452 302 10; +#X obj 106 129 vabs; +#X msg 105 95 1 2 3 -4 -5 -6; +#X obj 105 165 print; +#X connect 0 0 2 0; +#X connect 1 0 0 0; diff --git a/vabs.c b/vabs.c new file mode 100644 index 0000000..c928c5e --- /dev/null +++ b/vabs.c @@ -0,0 +1,48 @@ +#include "defines.h" + +/*--------------- vabs ----------------*/ +/* absolute values of a list of floats */ + + +static t_class *vabs_class; + +typedef struct _vabs +{ + t_object x_obj; +} t_vabs; + + +static void vabs_perform(t_vabs *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, f>0?f:-f); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vabs_new() +{ + t_vabs *x=(t_vabs *)pd_new(vabs_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vabs_setup(void) +{ + vabs_class = class_new(gensym("vabs"), + (t_newmethod)vabs_new, 0, + sizeof(t_vabs), + CLASS_DEFAULT, + 0); + class_addlist(vabs_class, (t_method)vabs_perform); +} + diff --git a/vclip-help.pd b/vclip-help.pd new file mode 100644 index 0000000..e182755 --- /dev/null +++ b/vclip-help.pd @@ -0,0 +1,17 @@ +#N canvas 588 327 324 246 10; +#X obj 11 141 vclip -1 1; +#X obj 11 196 print; +#X msg 11 30 -4 -3 -2 -1 0 1 2 3 4; +#X floatatom 73 64 5 0 0; +#X floatatom 118 103 5 0 0; +#X text 10 6 vclip clips each element in a vector; +#X text 23 166 arguments: lower bound \, upper bound; +#X text 20 52 input; +#X text 79 81 lower bound; +#X text 121 120 upper bound; +#X text 252 220 j#|@2002; +#X obj 274 200 SMLib-help; +#X connect 0 0 1 0; +#X connect 2 0 0 0; +#X connect 3 0 0 1; +#X connect 4 0 0 2; diff --git a/vclip.c b/vclip.c new file mode 100644 index 0000000..4a11ef5 --- /dev/null +++ b/vclip.c @@ -0,0 +1,58 @@ +#include "defines.h" + +/*--------------- vclip ----------------*/ +/* clips a vector */ + + +static t_class *vclip_class; + +typedef struct _vclip +{ + t_object x_obj; + float m_lo; + float m_hi; +} t_vclip; + + +static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float lo,hi; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + lo=x->m_lo; + hi=x->m_hi; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, (fhi?hi:f))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vclip_new(t_float lo, t_float hi) +{ + t_vclip *x=(t_vclip *)pd_new(vclip_class); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + outlet_new(&x->x_obj, gensym("list")); + x->m_hi=hi; + x->m_lo=lo; + return (void *)x; +} + +void vclip_setup(void) +{ + vclip_class = class_new(gensym("vclip"), + (t_newmethod)vclip_new, 0, + sizeof(t_vclip), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vclip_class, (t_method)vclip_perform); +} + diff --git a/vcog-help.pd b/vcog-help.pd new file mode 100644 index 0000000..0e8d67f --- /dev/null +++ b/vcog-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 471 125 10; +#X msg 18 40 1 2 3 4; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib-help; +#X obj 52 69 vcog; +#X text 16 14 vcog computes the center of gravity of a list of floats +; +#X msg 134 40 0 1 0 1; +#X msg 199 40 0 0 1 1; +#X msg 263 40 8; +#X msg 144 74 1 -1; +#X text 142 94 zero sum causes no output; +#X connect 0 0 5 0; +#X connect 2 0 5 0; +#X connect 5 0 1 0; +#X connect 7 0 5 0; +#X connect 8 0 5 0; +#X connect 9 0 5 0; +#X connect 10 0 5 0; diff --git a/vcog.c b/vcog.c new file mode 100644 index 0000000..1dd68a4 --- /dev/null +++ b/vcog.c @@ -0,0 +1,43 @@ +#include "defines.h" + +/*--------------- vcog ---------------*/ + +static t_class *vcog_class; + +typedef struct _vcog +{ + t_object x_obj; +} t_vcog; + + +static void vcog_perform(t_vcog *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + float wsum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp; + wsum+= tmp*i; + } + if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0f+(wsum/sum)); +} + +static void *vcog_new( t_float halfDecayTime) +{ + t_vcog *x=(t_vcog *)pd_new(vcog_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vcog_setup(void) +{ + vcog_class = class_new(gensym("vcog"), + (t_newmethod)vcog_new, 0, + sizeof(t_vcog), + CLASS_DEFAULT, + 0); + class_addlist(vcog_class, (t_method)vcog_perform); +} + diff --git a/vdbtorms-help.pd b/vdbtorms-help.pd new file mode 100644 index 0000000..695fdc6 --- /dev/null +++ b/vdbtorms-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 283 118 10; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib-help; +#X msg 15 33 100 97 94; +#X text 10 6 db to rms on a vector; +#X obj 15 56 vdbtorms; +#X obj 15 80 print vdbtorms; +#X connect 2 0 4 0; +#X connect 4 0 5 0; diff --git a/vdbtorms.c b/vdbtorms.c new file mode 100644 index 0000000..ab954f6 --- /dev/null +++ b/vdbtorms.c @@ -0,0 +1,56 @@ +#include "defines.h" + +/*--------------- vdbtorms ----------------*/ + +static t_class *vdbtorms_class; + +typedef struct _vdbtorms +{ + t_object x_obj; +} t_vdbtorms; + +float dbtorms(float f) +{ + if (f <= 0) + return(0); + else + { + if (f > 485) + f = 485; + } + return (float)(exp((LOGTEN * 0.05) * (f-100.))); +} + +static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, dbtorms(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vdbtorms_new() +{ + t_vdbtorms *x=(t_vdbtorms *)pd_new(vdbtorms_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vdbtorms_setup(void) +{ + vdbtorms_class = class_new(gensym("vdbtorms"), + (t_newmethod)vdbtorms_new, 0, + sizeof(t_vdbtorms), + CLASS_DEFAULT, + 0); + class_addlist(vdbtorms_class, (t_method)vdbtorms_perform); +} + diff --git a/vdelta-help.pd b/vdelta-help.pd new file mode 100644 index 0000000..bda6821 --- /dev/null +++ b/vdelta-help.pd @@ -0,0 +1,29 @@ +#N canvas 619 449 433 228 10; +#X msg 5 30 1 1 1 1 1 1 1 1 1 1; +#X msg 5 52 1 0 1 0 1 0 1 0 1 0; +#X msg 5 74 0 1 0 1 0 1 0 1 0 1; +#X msg 5 96 0 0 0 0 0 0 0 0 0 0; +#X msg 5 118 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 5 140 0 0 0 0 0 1 1 1 1 1; +#X text 352 205 j#|@2002; +#X obj 373 184 SMLib-help; +#X text 7 3 vdelta: difference between consecutive vectors; +#X obj 5 193 print vdelta; +#X msg 221 31 0; +#X text 111 162 sending a vector of a different; +#X text 111 178 length resets its state; +#X obj 5 170 vdelta; +#X msg 221 57 0 0 0; +#X msg 221 79 1 2 3; +#X msg 221 101 3 2 1; +#X connect 0 0 13 0; +#X connect 1 0 13 0; +#X connect 2 0 13 0; +#X connect 3 0 13 0; +#X connect 4 0 13 0; +#X connect 5 0 13 0; +#X connect 10 0 13 0; +#X connect 13 0 9 0; +#X connect 14 0 13 0; +#X connect 15 0 13 0; +#X connect 16 0 13 0; diff --git a/vdelta.c b/vdelta.c new file mode 100644 index 0000000..cc809db --- /dev/null +++ b/vdelta.c @@ -0,0 +1,75 @@ +#include "defines.h" + +/*--------------- vdelta ----------------------------*/ +/* differences between element in succesive vectors */ + +static t_class *vdelta_class; + +typedef struct _vdelta +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_prev; + int m_n; +} t_vdelta; + + +static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_prev) + freebytes(x->m_prev,x->m_n); + x->m_prev=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_prev[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_prev; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, f-*fp); + app++; + *fp++=f; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vdelta_new() +{ + t_vdelta *x=(t_vdelta *)pd_new(vdelta_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_n=0; + x->m_prev=0; + return (void *)x; +} + +static void vdelta_free(t_vdelta *x) +{ + freebytes(x->m_prev,x->m_n); +} + +void vdelta_setup(void) +{ + vdelta_class = class_new(gensym("vdelta"), + (t_newmethod)vdelta_new, (t_method)vdelta_free, + sizeof(t_vdelta), + CLASS_DEFAULT, + 0); + class_addlist(vdelta_class, (t_method)vdelta_perform); +} diff --git a/vfmod-help.pd b/vfmod-help.pd new file mode 100644 index 0000000..fb7d7a9 --- /dev/null +++ b/vfmod-help.pd @@ -0,0 +1,17 @@ +#N canvas 163 334 442 175 10; +#X text 364 147 j#|@2002; +#X obj 386 127 SMLib-help; +#X text 10 6 vfmod computes the modulo of each element in a vector +; +#X obj 15 127 print; +#X floatatom 66 81 5 0 0; +#X text 79 103 base; +#X text 78 119 base zero becomes one; +#X msg 15 33 0 0.5 1 1.5 2 2.5 3 3.5; +#X msg 26 58 0 -0.5 -1 -1.5 -2 -2.5 -3 -3.5; +#X obj 15 101 vfmod 2; +#X text 78 134 default argument is 1; +#X connect 4 0 9 1; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 3 0; diff --git a/vfmod.c b/vfmod.c new file mode 100644 index 0000000..7b7d1af --- /dev/null +++ b/vfmod.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- vfmod ----------------*/ +/* floating point modulo of a vector */ + + +static t_class *vfmod_class; + +typedef struct _vfmod +{ + t_object x_obj; + float m_y; +} t_vfmod; + + +static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float y; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + y=x->m_y; + if (y==0.0f) + y=1.0f; + for (i = 0; i < argc; i++) + { + SETFLOAT(app, (float)fmod(atom_getfloat(argv++),y)); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vfmod_new(t_float y) +{ + t_vfmod *x=(t_vfmod *)pd_new(vfmod_class); + + floatinlet_new(&x->x_obj, &x->m_y); + + outlet_new(&x->x_obj, gensym("list")); + if (y==0.0f) + y=1.0f; + x->m_y=y; + return (void *)x; +} + +void vfmod_setup(void) +{ + vfmod_class = class_new(gensym("vfmod"), + (t_newmethod)vfmod_new, 0, + sizeof(t_vfmod), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vfmod_class, (t_method)vfmod_perform); +} + diff --git a/vftom-help.pd b/vftom-help.pd new file mode 100644 index 0000000..cdaf679 --- /dev/null +++ b/vftom-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 281 116 10; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib-help; +#X text 10 6 frequency to midi on a vector; +#X msg 15 33 440 446.164 880; +#X obj 15 56 vftom; +#X obj 15 80 print vftom; +#X connect 3 0 4 0; +#X connect 4 0 5 0; diff --git a/vftom.c b/vftom.c new file mode 100644 index 0000000..6355006 --- /dev/null +++ b/vftom.c @@ -0,0 +1,49 @@ +#include "defines.h" + +/*--------------- vftom ----------------*/ + +static t_class *vftom_class; + +typedef struct _vftom +{ + t_object x_obj; +} t_vftom; + +float ftom(float f) +{ + return (float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); +} + +static void vftom_perform(t_vftom *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, ftom(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vftom_new() +{ + t_vftom *x=(t_vftom *)pd_new(vftom_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vftom_setup(void) +{ + vftom_class = class_new(gensym("vftom"), + (t_newmethod)vftom_new, 0, + sizeof(t_vftom), + CLASS_DEFAULT, + 0); + class_addlist(vftom_class, (t_method)vftom_perform); +} + diff --git a/vlavg-help.pd b/vlavg-help.pd new file mode 100644 index 0000000..764e598 --- /dev/null +++ b/vlavg-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 464 314 10; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlavg 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X obj 8 224 vlavg 6; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 7 3 vlavg: vector leaky average; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 8 275 s array_vlavg; +#X obj 397 264 SMLib-help; +#X msg 27 201 decay 20; +#X connect 0 0 12 0; +#X connect 2 0 6 0; +#X connect 3 0 6 0; +#X connect 4 0 6 0; +#X connect 5 0 6 0; +#X connect 6 0 0 0; +#X connect 7 0 6 0; +#X connect 8 0 6 0; +#X connect 14 0 6 0; diff --git a/vlavg.c b/vlavg.c new file mode 100644 index 0000000..1e6ba98 --- /dev/null +++ b/vlavg.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlavg -----------------------*/ +/* leaky average of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlavg_class; + +typedef struct _vlavg +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_avg; + int m_n; +} t_vlavg; + + +static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_avg) + freebytes(x->m_avg,x->m_n); + x->m_avg=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_avg[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_avg; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp = *fp * m_c_leak + f * m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlavg_setHalfDecay(t_vlavg *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlavg_new(t_float halfDecayTime) +{ + t_vlavg *x=(t_vlavg *)pd_new(vlavg_class); + outlet_new(&x->x_obj, gensym("list")); + vlavg_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_avg=0; + return (void *)x; +} + +static void vlavg_free(t_vlavg *x) +{ + freebytes(x->m_avg,x->m_n); +} + +void vlavg_setup(void) +{ + vlavg_class = class_new(gensym("vlavg"), + (t_newmethod)vlavg_new, (t_method)vlavg_free, + sizeof(t_vlavg), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlavg_class, (t_method)vlavg_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlavg_class, (t_method)vlavg_perform); +} diff --git a/vlmax-help.pd b/vlmax-help.pd new file mode 100644 index 0000000..b8a40d2 --- /dev/null +++ b/vlmax-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 466 316 10; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlmax 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 397 264 SMLib-help; +#X obj 8 224 vlmax 6; +#X obj 8 275 s array_vlmax; +#X msg 27 201 decay 20; +#X text 9 4 vlmax: vector leaky maximum; +#X connect 0 0 12 0; +#X connect 2 0 11 0; +#X connect 3 0 11 0; +#X connect 4 0 11 0; +#X connect 5 0 11 0; +#X connect 6 0 11 0; +#X connect 7 0 11 0; +#X connect 11 0 0 0; +#X connect 13 0 11 0; diff --git a/vlmax.c b/vlmax.c new file mode 100644 index 0000000..a566f49 --- /dev/null +++ b/vlmax.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlmax -----------------------*/ +/* leaky maximum of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlmax_class; + +typedef struct _vlmax +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_max; + int m_n; +} t_vlmax; + + +static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_max) + freebytes(x->m_max,x->m_n); + x->m_max=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_max[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_max; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp =(f > *fp ) ? f : *fp *m_c_leak + f*m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlmax_setHalfDecay(t_vlmax *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlmax_new(t_float halfDecayTime) +{ + t_vlmax *x=(t_vlmax *)pd_new(vlmax_class); + outlet_new(&x->x_obj, gensym("list")); + vlmax_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_max=0; + return (void *)x; +} + +static void vlmax_free(t_vlmax *x) +{ + freebytes(x->m_max,x->m_n); +} + +void vlmax_setup(void) +{ + vlmax_class = class_new(gensym("vlmax"), + (t_newmethod)vlmax_new, (t_method)vlmax_free, + sizeof(t_vlmax), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlmax_class, (t_method)vlmax_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlmax_class, (t_method)vlmax_perform); +} diff --git a/vlmin-help.pd b/vlmin-help.pd new file mode 100644 index 0000000..2234cef --- /dev/null +++ b/vlmin-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 466 316 10; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlmin 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 397 264 SMLib-help; +#X obj 8 275 s array_vlmax; +#X msg 27 201 decay 20; +#X text 7 3 vlmin: vector leaky minimum; +#X obj 8 224 vlmin 6; +#X connect 0 0 11 0; +#X connect 2 0 14 0; +#X connect 3 0 14 0; +#X connect 4 0 14 0; +#X connect 5 0 14 0; +#X connect 6 0 14 0; +#X connect 7 0 14 0; +#X connect 12 0 14 0; +#X connect 14 0 0 0; diff --git a/vlmin.c b/vlmin.c new file mode 100644 index 0000000..b839826 --- /dev/null +++ b/vlmin.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlmin -----------------------*/ +/* leaky minimum of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlmin_class; + +typedef struct _vlmin +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_min; + int m_n; +} t_vlmin; + + +static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_min) + freebytes(x->m_min,x->m_n); + x->m_min=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_min[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_min; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp =(f < *fp ) ? f : *fp *m_c_leak + f*m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlmin_setHalfDecay(t_vlmin *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlmin_new(t_float halfDecayTime) +{ + t_vlmin *x=(t_vlmin *)pd_new(vlmin_class); + outlet_new(&x->x_obj, gensym("list")); + vlmin_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_min=0; + return (void *)x; +} + +static void vlmin_free(t_vlmin *x) +{ + freebytes(x->m_min,x->m_n); +} + +void vlmin_setup(void) +{ + vlmin_class = class_new(gensym("vlmin"), + (t_newmethod)vlmin_new, (t_method)vlmin_free, + sizeof(t_vlmin), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlmin_class, (t_method)vlmin_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlmin_class, (t_method)vlmin_perform); +} diff --git a/vlrange-help.pd b/vlrange-help.pd new file mode 100644 index 0000000..1cab3c3 --- /dev/null +++ b/vlrange-help.pd @@ -0,0 +1,9 @@ +#N canvas 406 191 400 214 10; +#X text 192 79 j#|@2002; +#X obj 214 59 SMLib-help; +#X obj 15 57 vmtof; +#X text 10 6 midi to frequency on a vector; +#X msg 15 33 69 70 81; +#X obj 15 80 print vmtof; +#X connect 2 0 5 0; +#X connect 4 0 2 0; diff --git a/vlrange.c b/vlrange.c new file mode 100644 index 0000000..07b383f --- /dev/null +++ b/vlrange.c @@ -0,0 +1,99 @@ +#include "defines.h" + +/*--------------- vlrange -----------------------*/ +/* leaky range of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlrange_class; + +typedef struct _vlrange +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_min; + float *m_max; + int m_n; +} t_vlrange; + + +static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fmin, *fmax; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_min) + { + freebytes(x->m_min,x->m_n); + freebytes(x->m_max,x->m_n); + } + x->m_min=(float*)getbytes(argc*sizeof(float)); + x->m_max=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_min[i]=0.0f; + x->m_max[i]=0.0f; + } + x->m_n=argc; + } + + fmin=x->m_min; + fmax=x->m_max; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fmax =(f > *fmax ) ? f : *fmax *m_c_leak + f*m_leak; + *fmin =(f < *fmin ) ? f : *fmin *m_c_leak + f*m_leak; + SETFLOAT(app, *fmax-*fmin); + app++; + fmax++; + fmin++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlrange_setHalfDecay(t_vlrange *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlrange_new(t_float halfDecayTime) +{ + t_vlrange *x=(t_vlrange *)pd_new(vlrange_class); + outlet_new(&x->x_obj, gensym("list")); + vlrange_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_min=0; + x->m_max=0; + return (void *)x; +} + +static void vlrange_free(t_vlrange *x) +{ + freebytes(x->m_max,x->m_n); + freebytes(x->m_min,x->m_n); +} + +void vlrange_setup(void) +{ + vlrange_class = class_new(gensym("vlrange"), + (t_newmethod)vlrange_new, (t_method)vlrange_free, + sizeof(t_vlrange), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlrange_class, (t_method)vlrange_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlrange_class, (t_method)vlrange_perform); +} diff --git a/vmax-help.pd b/vmax-help.pd new file mode 100644 index 0000000..d615216 --- /dev/null +++ b/vmax-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 473 127 10; +#X floatatom 35 104 5 0 0; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib-help; +#X msg 133 47 0; +#X msg 168 47 0 1 0 1; +#X msg 243 48 0 0 1 1; +#X text 14 3 vcog computes maximum of a list of floats; +#X obj 49 76 vmax; +#X floatatom 86 104 5 0 0; +#X msg 15 47 1 2 3 1; +#X msg 81 47 3 4 1; +#X text 13 21 and the location of the first occurance of the maximum +; +#X connect 3 0 7 0; +#X connect 4 0 7 0; +#X connect 5 0 7 0; +#X connect 7 0 0 0; +#X connect 7 1 8 0; +#X connect 9 0 7 0; +#X connect 10 0 7 0; diff --git a/vmax.c b/vmax.c new file mode 100644 index 0000000..ac56423 --- /dev/null +++ b/vmax.c @@ -0,0 +1,52 @@ +#include "defines.h" + +/*--------------- vmax ---------------*/ +/* maximum value in a list of float + and its location (index) +*/ + +static t_class *vmax_class; + +typedef struct _vmax +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vmax; + + +static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int maxi; + float max=-MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (f>max) + { + max=f; + maxi=i; + } + } + outlet_float(x->x_obj.ob_outlet, max); + outlet_float(x->m_out_maxi, (float)(maxi+1)); +} + +static void *vmax_new( t_float halfDecayTime) +{ + t_vmax *x=(t_vmax *)pd_new(vmax_class); + outlet_new(&x->x_obj, gensym("float")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vmax_setup(void) +{ + vmax_class = class_new(gensym("vmax"), + (t_newmethod)vmax_new, 0, + sizeof(t_vmax), + CLASS_DEFAULT, + 0); + class_addlist(vmax_class, (t_method)vmax_perform); +} + diff --git a/vmin-help.pd b/vmin-help.pd new file mode 100644 index 0000000..a6bc097 --- /dev/null +++ b/vmin-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 473 127 10; +#X floatatom 35 104 5 0 0; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib-help; +#X msg 133 47 0; +#X msg 168 47 0 1 0 1; +#X msg 236 47 0 0 1 1; +#X floatatom 86 104 5 0 0; +#X msg 15 47 1 2 3 1; +#X msg 81 47 3 4 1; +#X text 14 3 vcog computes minimum of a list of floats; +#X text 13 21 and the location of the first occurance of the minimum +; +#X obj 49 76 vmin; +#X connect 3 0 11 0; +#X connect 4 0 11 0; +#X connect 5 0 11 0; +#X connect 7 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 0 0; +#X connect 11 1 6 0; diff --git a/vmin.c b/vmin.c new file mode 100644 index 0000000..a0b578e --- /dev/null +++ b/vmin.c @@ -0,0 +1,52 @@ +#include "defines.h" + +/*--------------- vmin ---------------*/ +/* maximum value in a list of float + and its location (index) +*/ + +static t_class *vmin_class; + +typedef struct _vmin +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vmin; + + +static void vmin_perform(t_vmin *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int mini; + float min=MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (fx_obj.ob_outlet, min); + outlet_float(x->m_out_maxi, (float)(mini+1)); +} + +static void *vmin_new( t_float halfDecayTime) +{ + t_vmin *x=(t_vmin *)pd_new(vmin_class); + outlet_new(&x->x_obj, gensym("float")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vmin_setup(void) +{ + vmin_class = class_new(gensym("vmin"), + (t_newmethod)vmin_new, 0, + sizeof(t_vmin), + CLASS_DEFAULT, + 0); + class_addlist(vmin_class, (t_method)vmin_perform); +} + diff --git a/vmtof-help.pd b/vmtof-help.pd new file mode 100644 index 0000000..1cab3c3 --- /dev/null +++ b/vmtof-help.pd @@ -0,0 +1,9 @@ +#N canvas 406 191 400 214 10; +#X text 192 79 j#|@2002; +#X obj 214 59 SMLib-help; +#X obj 15 57 vmtof; +#X text 10 6 midi to frequency on a vector; +#X msg 15 33 69 70 81; +#X obj 15 80 print vmtof; +#X connect 2 0 5 0; +#X connect 4 0 2 0; diff --git a/vmtof.c b/vmtof.c new file mode 100644 index 0000000..828dcb6 --- /dev/null +++ b/vmtof.c @@ -0,0 +1,51 @@ +#include "defines.h" + +/*--------------- vmtof ----------------*/ + +static t_class *vmtof_class; + +typedef struct _vmtof +{ + t_object x_obj; +} t_vmtof; + +float mtof(float f) +{ + if (f <= -1500) return(0); + else if (f > 1499) return(mtof(1499)); + else return (float)(8.17579891564 * exp(.0577622650 * f)); +} + +static void vmtof_perform(t_vmtof *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, mtof(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vmtof_new() +{ + t_vmtof *x=(t_vmtof *)pd_new(vmtof_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vmtof_setup(void) +{ + vmtof_class = class_new(gensym("vmtof"), + (t_newmethod)vmtof_new, 0, + sizeof(t_vmtof), + CLASS_DEFAULT, + 0); + class_addlist(vmtof_class, (t_method)vmtof_perform); +} + diff --git a/vnmax-help.pd b/vnmax-help.pd new file mode 100644 index 0000000..1cab3c3 --- /dev/null +++ b/vnmax-help.pd @@ -0,0 +1,9 @@ +#N canvas 406 191 400 214 10; +#X text 192 79 j#|@2002; +#X obj 214 59 SMLib-help; +#X obj 15 57 vmtof; +#X text 10 6 midi to frequency on a vector; +#X msg 15 33 69 70 81; +#X obj 15 80 print vmtof; +#X connect 2 0 5 0; +#X connect 4 0 2 0; diff --git a/vnmax.c b/vnmax.c new file mode 100644 index 0000000..7003f6d --- /dev/null +++ b/vnmax.c @@ -0,0 +1,55 @@ +#include "defines.h" + +/*--------------- vnmax ---------------*/ +/* maximum n values in a list of float + and their locations (indices) +*/ + +//// UNCOMPLETE + + +static t_class *vnmax_class; + +typedef struct _vnmax +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vnmax; + + +static void vnmax_perform(t_vnmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int maxi; + float max=-MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (f>max) + { + max=f; + maxi=i; + } + } + outlet_float(x->x_obj.ob_outlet, max); + outlet_float(x->m_out_maxi, (float)(maxi+1)); +} + +static void *vnmax_new( t_float halfDecayTime) +{ + t_vnmax *x=(t_vnmax *)pd_new(vnmax_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vnmax_setup(void) +{ + vnmax_class = class_new(gensym("vnmax"), + (t_newmethod)vnmax_new, 0, + sizeof(t_vnmax), + CLASS_DEFAULT, + 0); + class_addlist(vnmax_class, (t_method)vnmax_perform); +} + diff --git a/vpow-help.pd b/vpow-help.pd new file mode 100644 index 0000000..7809a54 --- /dev/null +++ b/vpow-help.pd @@ -0,0 +1,15 @@ +#N canvas 163 334 444 177 10; +#X text 364 147 j#|@2002; +#X obj 386 127 SMLib-help; +#X obj 15 127 print; +#X floatatom 66 81 5 0 0 0 - - -; +#X text 78 134 default argument is 1; +#X text 10 6 vpow computes y(i)=x(i)^a; +#X text 79 103 a; +#X text 79 117 a zero becomes one; +#X obj 15 101 vpow 2; +#X msg 15 33 0.01 0.5 1 1.5 2 2.5 3 3.5 0; +#X text 27 56 if (x(i)<=0) then y(i)=-1000; +#X connect 3 0 8 1; +#X connect 8 0 2 0; +#X connect 9 0 8 0; diff --git a/vpow.c b/vpow.c new file mode 100644 index 0000000..6859859 --- /dev/null +++ b/vpow.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- vpow ----------------*/ + +static t_class *vpow_class; + +typedef struct _vpow +{ + t_object x_obj; + float m_y; +} t_vpow; + + +static void vpow_perform(t_vpow *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float y; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + y=x->m_y; + if (y==0.0f) + y=1.0f; + for (i = 0; i < argc; i++) + { + float x=atom_getfloat(argv++); + if (x>0) + x=(float)powf(x,y); + else + x=-1000.; + SETFLOAT(app, x); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vpow_new(t_float y) +{ + t_vpow *x=(t_vpow *)pd_new(vpow_class); + + floatinlet_new(&x->x_obj, &x->m_y); + + outlet_new(&x->x_obj, gensym("list")); + if (y==0.0f) + y=1.0f; + x->m_y=y; + return (void *)x; +} + +void vpow_setup(void) +{ + vpow_class = class_new(gensym("vpow"), + (t_newmethod)vpow_new, 0, + sizeof(t_vpow), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vpow_class, (t_method)vpow_perform); +} + diff --git a/vrms-help.pd b/vrms-help.pd new file mode 100644 index 0000000..dce1a77 --- /dev/null +++ b/vrms-help.pd @@ -0,0 +1,15 @@ +#N canvas 381 509 392 123 10; +#X msg 17 39 1 2 3 4; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 315 100 j#|@2002; +#X obj 337 78 SMLib-help; +#X obj 52 69 vrms; +#X text 16 14 vrms computes the root-mean-square of a vector; +#X msg 134 40 1 1 1 1; +#X msg 200 40 1 -1 1 -1; +#X connect 0 0 5 0; +#X connect 2 0 5 0; +#X connect 5 0 1 0; +#X connect 7 0 5 0; +#X connect 8 0 5 0; diff --git a/vrms.c b/vrms.c new file mode 100644 index 0000000..52b8d6d --- /dev/null +++ b/vrms.c @@ -0,0 +1,41 @@ +#include "defines.h" + +/*--------------- vrms ---------------*/ + +static t_class *vrms_class; + +typedef struct _vrms +{ + t_object x_obj; +} t_vrms; + + +static void vrms_perform(t_vrms *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp*tmp; + } + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sum/argc)); +} + +static void *vrms_new( t_float halfDecayTime) +{ + t_vrms *x=(t_vrms *)pd_new(vrms_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vrms_setup(void) +{ + vrms_class = class_new(gensym("vrms"), + (t_newmethod)vrms_new, 0, + sizeof(t_vrms), + CLASS_DEFAULT, + 0); + class_addlist(vrms_class, (t_method)vrms_perform); +} + diff --git a/vrmstodb-help.pd b/vrmstodb-help.pd new file mode 100644 index 0000000..2651d44 --- /dev/null +++ b/vrmstodb-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 283 118 10; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib-help; +#X text 10 6 frequency to midi on a vector; +#X obj 15 56 vrmstodb; +#X msg 15 33 100 97 94; +#X obj 15 80 print vrmstodb; +#X connect 3 0 5 0; +#X connect 4 0 3 0; diff --git a/vrmstodb.c b/vrmstodb.c new file mode 100644 index 0000000..d375bf9 --- /dev/null +++ b/vrmstodb.c @@ -0,0 +1,54 @@ +#include "defines.h" + +/*--------------- vrmstodb ----------------*/ + +static t_class *vrmstodb_class; + +typedef struct _vrmstodb +{ + t_object x_obj; +} t_vrmstodb; + +float rmstodb(float f) +{ + if (f <= 0) return (0); + else + { + float val = (float)(100 + 20./LOGTEN * log(f)); + return (val < 0 ? 0 : val); + } +} + +static void vrmstodb_perform(t_vrmstodb *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, rmstodb(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vrmstodb_new() +{ + t_vrmstodb *x=(t_vrmstodb *)pd_new(vrmstodb_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vrmstodb_setup(void) +{ + vrmstodb_class = class_new(gensym("vrmstodb"), + (t_newmethod)vrmstodb_new, 0, + sizeof(t_vrmstodb), + CLASS_DEFAULT, + 0); + class_addlist(vrmstodb_class, (t_method)vrmstodb_perform); +} + diff --git a/vstd-help.pd b/vstd-help.pd new file mode 100644 index 0000000..32dce16 --- /dev/null +++ b/vstd-help.pd @@ -0,0 +1,15 @@ +#N canvas 381 509 394 125 10; +#X msg 17 39 1 2 3 4; +#X floatatom 51 95 5 0 0; +#X msg 84 40 3 4 5; +#X text 315 100 j#|@2002; +#X obj 337 78 SMLib-help; +#X msg 134 40 1 1 1 1; +#X obj 51 70 vstd; +#X msg 200 40 1 -1 1 -1 1; +#X text 16 14 vstd computes the standard deviation of a vector; +#X connect 0 0 6 0; +#X connect 2 0 6 0; +#X connect 5 0 6 0; +#X connect 6 0 1 0; +#X connect 7 0 6 0; diff --git a/vstd.c b/vstd.c new file mode 100644 index 0000000..538cb94 --- /dev/null +++ b/vstd.c @@ -0,0 +1,45 @@ +#include "defines.h" + +/*--------------- vstd ---------------*/ + +static t_class *vstd_class; + +typedef struct _vstd +{ + t_object x_obj; +} t_vstd; + + +static void vstd_perform(t_vstd *x, t_symbol *s, int argc, t_atom *argv) +{ + float sumsq=0.0f; + float sum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sumsq+= tmp*tmp; + sum+=tmp; + } + sumsq/=argc; + sum/=argc; + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sumsq-sum*sum)); +} + +static void *vstd_new( t_float halfDecayTime) +{ + t_vstd *x=(t_vstd *)pd_new(vstd_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vstd_setup(void) +{ + vstd_class = class_new(gensym("vstd"), + (t_newmethod)vstd_new, 0, + sizeof(t_vstd), + CLASS_DEFAULT, + 0); + class_addlist(vstd_class, (t_method)vstd_perform); +} + diff --git a/vsum-help.pd b/vsum-help.pd new file mode 100644 index 0000000..31ab009 --- /dev/null +++ b/vsum-help.pd @@ -0,0 +1,13 @@ +#N canvas 468 275 355 125 10; +#X text 16 14 vsum computes the sum of a list of floats; +#X msg 17 39 1 2 3 4; +#X obj 52 69 vsum; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 275 102 j#|@2002; +#X obj 297 80 SMLib-help; +#X msg 136 40 0; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 4 0 2 0; +#X connect 7 0 2 0; diff --git a/vsum.c b/vsum.c new file mode 100644 index 0000000..dd49f4c --- /dev/null +++ b/vsum.c @@ -0,0 +1,40 @@ +#include "defines.h" + +/*--------------- vsum ---------------*/ + +static t_class *vsum_class; + +typedef struct _vsum +{ + t_object x_obj; +} t_vsum; + + +static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + int i; + for (i = 0; i < argc; i++) + { + sum+= atom_getfloat(&argv[i]); + } + outlet_float(x->x_obj.ob_outlet, sum); +} + +static void *vsum_new() +{ + t_vsum *x=(t_vsum *)pd_new(vsum_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vsum_setup(void) +{ + vsum_class = class_new(gensym("vsum"), + (t_newmethod)vsum_new, 0, + sizeof(t_vsum), + CLASS_DEFAULT, + 0); + class_addlist(vsum_class, (t_method)vsum_perform); +} + diff --git a/vthreshold-help.pd b/vthreshold-help.pd new file mode 100644 index 0000000..1cab3c3 --- /dev/null +++ b/vthreshold-help.pd @@ -0,0 +1,9 @@ +#N canvas 406 191 400 214 10; +#X text 192 79 j#|@2002; +#X obj 214 59 SMLib-help; +#X obj 15 57 vmtof; +#X text 10 6 midi to frequency on a vector; +#X msg 15 33 69 70 81; +#X obj 15 80 print vmtof; +#X connect 2 0 5 0; +#X connect 4 0 2 0; diff --git a/vthreshold.c b/vthreshold.c new file mode 100644 index 0000000..106cf72 --- /dev/null +++ b/vthreshold.c @@ -0,0 +1,106 @@ +/* --------------------- vthreshold ----------------------------- */ + +#include "defines.h" +#include "memory.h" + +static t_class *vthreshold_class; + +typedef struct _vthreshold +{ + t_object x_obj; + t_outlet *x_outlet1; /* bang out for high thresh */ + t_outlet *x_outlet2; /* bang out for low thresh */ + int *x_state; /* 1 = high, 0 = low */ + int x_n; + float x_hithresh; /* value of high vthreshold */ + float x_lothresh; /* value of low vthreshold */ + float x_hideadtime; /* hi dead */ + float x_lodeadtime; /* lo dead */ +} t_vthreshold; + + /* "set" message to specify vthresholds and dead times */ +static void vthreshold_set(t_vthreshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime, + t_floatarg nf) +{ + if (lothresh > hithresh) + lothresh = hithresh; + x->x_hithresh = hithresh; + x->x_hideadtime = hideadtime; + x->x_lothresh = lothresh; + x->x_lodeadtime = lodeadtime; + freebytes(x->x_state,x->x_n); + x->x_n=(int)nf; + x->x_state = (int *)getbytes(sizeof(int)*x->x_n); + memset(x->x_state , 0, x->x_n); +} + +static t_vthreshold *vthreshold_new(t_floatarg hithresh, + t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime, t_floatarg n) +{ + t_vthreshold *x = (t_vthreshold *) + pd_new(vthreshold_class); + x->x_state = 0; /* low state */ + x->x_outlet1 = outlet_new(&x->x_obj, gensym("float")); + x->x_outlet2 = outlet_new(&x->x_obj, gensym("float")); + vthreshold_set(x, hithresh, hideadtime, lothresh, lodeadtime, n); + return (x); +} + +static void vthreshold_free(t_vthreshold *x) +{ + freebytes(x->x_state,x->x_n); +} + +static void vthreshold_perform(t_vthreshold *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int *state; + + state=x->x_state; + if (argc>x->x_n) argc=x->x_n; + for (i=0;ix->x_hithresh) + { + outlet_float(x->x_outlet1, (float)i); // on + *state=1; + } + } + else + { + if (fx_lothresh) + { + outlet_float(x->x_outlet2, (float)i); // off + *state=-1; + } + } + state++; + } +} + + +static void vthreshold_ff(t_vthreshold *x) +{ + freebytes(x->x_state,x->x_n); +} + +void vthreshold_setup( void) +{ + vthreshold_class = class_new(gensym("vthreshold"), + (t_newmethod)vthreshold_new, (t_method)vthreshold_free, + sizeof(t_vthreshold), 0, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + + class_addlist(vthreshold_class, (t_method)vthreshold_perform); + class_addmethod(vthreshold_class, (t_method)vthreshold_set, + gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); +// class_addmethod(vthreshold_class, (t_method)vthreshold_ft1, +// gensym("ft1"), A_FLOAT, 0); +} diff --git a/vvconv-help.pd b/vvconv-help.pd new file mode 100644 index 0000000..3ad20a3 --- /dev/null +++ b/vvconv-help.pd @@ -0,0 +1,35 @@ +#N canvas 482 447 441 276 10; +#X msg 132 78 1 2 1; +#X msg 132 53 1 0 1; +#X text 26 18 vvconv: convolution of 2 vectors; +#X text 357 244 j#|@2002; +#X msg 30 43 1; +#X obj 48 130 vvconv; +#X msg 331 80 1 2 1; +#X msg 229 68 1 0 0; +#X msg 331 55 1 0 1; +#X msg 229 45 1; +#X obj 247 132 vvconv -1 2 -1; +#X msg 230 92 1 0 1 0 0 1; +#X msg 31 90 1 0 1 0 0 1; +#X text 177 178 arguments: convolution kernel; +#X obj 377 225 SMLib-help; +#X obj 48 154 print vvconv; +#X obj 247 156 print vvconv; +#X text 2 202 length of output is the sum of input lengths minus one +; +#X msg 30 66 2 0 1; +#X msg 132 103 1 0 2; +#X connect 0 0 5 1; +#X connect 1 0 5 1; +#X connect 4 0 5 0; +#X connect 5 0 15 0; +#X connect 6 0 10 1; +#X connect 7 0 10 0; +#X connect 8 0 10 1; +#X connect 9 0 10 0; +#X connect 10 0 16 0; +#X connect 11 0 10 0; +#X connect 12 0 5 0; +#X connect 18 0 5 0; +#X connect 19 0 5 1; diff --git a/vvconv.c b/vvconv.c new file mode 100644 index 0000000..5541705 --- /dev/null +++ b/vvconv.c @@ -0,0 +1,151 @@ +#include "defines.h" + +/*--------------- vvconv ---------------*/ +/* vector convolution +*/ + +static t_class *vvconv_class; +static t_class *vvconv_scal_class; + +typedef struct _vvconv +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvconv; + + +static void vvconv_lst2(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvconv_lst(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1**x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, *fp++*f); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp++*f); + a++; + } + } else { + t_atom *a; + int i,j,n1,n2; + t_float *f; + t_float *g; + t_float *fp2=x->buf2; + fp = x->buf1; + n1=x->n1; + n2=x->n2; + n = n1 + n2 - 1; + f = (t_float *)getbytes(sizeof(t_float)*n); + g=f; + for(i=0;ix_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvconv_free(t_vvconv *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvconv_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvconv *x; + + if (argc-1){ + x = (t_vvconv *)pd_new(vvconv_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvconv *)pd_new(vvconv_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvconv_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvconv_setup(void) +{ + vvconv_class = class_new(gensym("vvconv"), (t_newmethod)vvconv_new, + (t_method)vvconv_free, sizeof(t_vvconv), 0, A_GIMME, 0); + class_addlist(vvconv_class, vvconv_lst); + class_addmethod (vvconv_class, (t_method)vvconv_lst2, gensym(""), A_GIMME, 0); + vvconv_scal_class = class_new(gensym("vv+"), 0, (t_method)vvconv_free, + sizeof(t_vvconv), 0, 0); + class_addlist(vvconv_scal_class, vvconv_lst); +} diff --git a/vvminus-help.pd b/vvminus-help.pd new file mode 100644 index 0000000..48c626b --- /dev/null +++ b/vvminus-help.pd @@ -0,0 +1,23 @@ +#N canvas 561 440 326 219 10; +#X msg 25 90 1 2 3; +#X msg 82 94 4 5 6; +#X msg 168 95 1 2 3; +#X msg 228 95 4; +#X msg 25 66 1; +#X msg 168 71 1; +#X text 248 191 j#|@2002; +#X text 18 10 vv- substracts two lists of floats; +#X text 18 26 or a float from a list of floats; +#X obj 49 124 vv-; +#X obj 189 125 vv- 0; +#X obj 268 170 SMLib-help; +#X obj 49 148 print vv-; +#X obj 189 149 print vv-; +#X connect 0 0 9 0; +#X connect 1 0 9 1; +#X connect 2 0 10 0; +#X connect 3 0 10 1; +#X connect 4 0 9 0; +#X connect 5 0 10 0; +#X connect 9 0 12 0; +#X connect 10 0 13 0; diff --git a/vvminus.c b/vvminus.c new file mode 100644 index 0000000..191850c --- /dev/null +++ b/vvminus.c @@ -0,0 +1,142 @@ +#include "defines.h" + +/*--------------- vvminus ---------------*/ +/* vector substraction +*/ + +static t_class *vvminus_class; +static t_class *vvminus_scal_class; + +typedef struct _vvminus +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvminus; + + +static void vvminus_lst2(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvminus_lst(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1-*x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, f-*fp++); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp++-f); + a++; + } + } else { + t_atom *a; + int i; + t_float *fp2=x->buf2; + fp = x->buf1; + n = x->n1; + if (x->n1!=x->n2){ + post("scalar multiplication: truncating vectors to the same length"); + if (x->n2n1)n=x->n2; + } + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + i=n; + while(i--){ + SETFLOAT(a, *fp++-*fp2++); + a++; + } + } + outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvminus_free(t_vvminus *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvminus_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvminus *x; + + if (argc-1){ + x = (t_vvminus *)pd_new(vvminus_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvminus *)pd_new(vvminus_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvminus_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvminus_setup(void) +{ + vvminus_class = class_new(gensym("vvminus"), (t_newmethod)vvminus_new, + (t_method)vvminus_free, sizeof(t_vvminus), 0, A_GIMME, 0); + class_addcreator((t_newmethod)vvminus_new, gensym("vv-"), A_GIMME, 0); + class_addlist(vvminus_class, vvminus_lst); + class_addmethod (vvminus_class, (t_method)vvminus_lst2, gensym(""), A_GIMME, 0); + vvminus_scal_class = class_new(gensym("vv-"), 0, (t_method)vvminus_free, + sizeof(t_vvminus), 0, 0); + class_addlist(vvminus_scal_class, vvminus_lst); +} diff --git a/vvplus-help.pd b/vvplus-help.pd new file mode 100644 index 0000000..04c3065 --- /dev/null +++ b/vvplus-help.pd @@ -0,0 +1,25 @@ +#N canvas 561 440 313 218 10; +#X obj 40 115 vv+; +#X msg 16 81 1 2 3; +#X msg 73 85 4 5 6; +#X msg 159 86 1 2 3; +#X msg 219 86 4; +#X obj 180 116 vv+ 0; +#X msg 16 57 1; +#X msg 159 62 1; +#X text 18 10 vv+ adds two lists of floats; +#X text 17 25 or a float to a list of floats; +#X msg 73 60 3 2 1; +#X obj 252 159 SMLib-help; +#X text 230 184 j#|@2002; +#X obj 40 139 print vv+; +#X obj 180 140 print vv+; +#X connect 0 0 13 0; +#X connect 1 0 0 0; +#X connect 2 0 0 1; +#X connect 3 0 5 0; +#X connect 4 0 5 1; +#X connect 5 0 14 0; +#X connect 6 0 0 0; +#X connect 7 0 5 0; +#X connect 10 0 0 1; diff --git a/vvplus.c b/vvplus.c new file mode 100644 index 0000000..a49ce39 --- /dev/null +++ b/vvplus.c @@ -0,0 +1,142 @@ +#include "defines.h" + +/*--------------- vvplus ---------------*/ +/* vector addition +*/ + +static t_class *vvplus_class; +static t_class *vvplus_scal_class; + +typedef struct _vvplus +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvplus; + + +static void vvplus_lst2(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvplus_lst(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1+*x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, *fp+++f); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp+++f); + a++; + } + } else { + t_atom *a; + int i; + t_float *fp2=x->buf2; + fp = x->buf1; + n = x->n1; + if (x->n1!=x->n2){ + post("scalar multiplication: truncating vectors to the same length"); + if (x->n2n1)n=x->n2; + } + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + i=n; + while(i--){ + SETFLOAT(a, *fp+++*fp2++); + a++; + } + } + outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvplus_free(t_vvplus *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvplus_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvplus *x; + + if (argc-1){ + x = (t_vvplus *)pd_new(vvplus_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvplus *)pd_new(vvplus_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvplus_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvplus_setup(void) +{ + vvplus_class = class_new(gensym("vvplus"), (t_newmethod)vvplus_new, + (t_method)vvplus_free, sizeof(t_vvplus), 0, A_GIMME, 0); + class_addcreator((t_newmethod)vvplus_new, gensym("vv+"), A_GIMME, 0); + class_addlist(vvplus_class, vvplus_lst); + class_addmethod (vvplus_class, (t_method)vvplus_lst2, gensym(""), A_GIMME, 0); + vvplus_scal_class = class_new(gensym("vv+"), 0, (t_method)vvplus_free, + sizeof(t_vvplus), 0, 0); + class_addlist(vvplus_scal_class, vvplus_lst); +} -- cgit v1.2.1