aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hasc~/hasc~.c100
-rw-r--r--hasc~/makefile103
2 files changed, 203 insertions, 0 deletions
diff --git a/hasc~/hasc~.c b/hasc~/hasc~.c
new file mode 100644
index 0000000..bb2e8b2
--- /dev/null
+++ b/hasc~/hasc~.c
@@ -0,0 +1,100 @@
+/*
+ * hssc~ : Highest Absolute Spectral Component, according to amplitude threshold
+ * Copyright (C) 2005 Edward Kelly <morph_2016@yahoo.co.uk>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "m_pd.h"
+#include <math.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+static t_class *hasc_tilde_class;
+
+typedef struct _hasc_tilde
+{
+ t_object x_obj;
+ t_float f;
+ t_float f_topbin, f_thresh;
+ t_outlet *f_hasc, *f_levs;
+} t_hasc_tilde;
+
+t_int *hasc_tilde_perform(t_int *w)
+{
+ t_hasc_tilde *x = (t_hasc_tilde *)(w[1]);
+ t_sample *real = (t_sample *)(w[2]);
+ t_sample *imag = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
+ int incr = 0;
+ double max = 0;
+ double vectorr, vectori;
+ double alpha;
+ x->f_topbin = 0;
+ x->f_thresh > 0 ? x->f_thresh : 1;
+
+ while (n--)
+ {
+ vectorr = (*real++);
+ vectori = (*imag++);
+ alpha = sqrt((vectorr * vectorr) + (vectori * vectori));
+ max = alpha > max ? alpha : max;
+ x->f_topbin = alpha > x->f_thresh ? incr : x->f_topbin;
+ incr++;
+ }
+ outlet_float(x->f_levs, (float)max);
+ outlet_float(x->f_hasc, x->f_topbin);
+
+ return(w+5);
+}
+
+void hasc_tilde_dsp(t_hasc_tilde *x, t_signal **sp)
+{
+ dsp_add(hasc_tilde_perform, 4, x,
+ sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+}
+
+void *hasc_tilde_new(t_floatarg f)
+{
+ t_hasc_tilde *x = (t_hasc_tilde *)pd_new(hasc_tilde_class);
+
+ x->f_thresh = f;
+
+ inlet_new (&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ floatinlet_new (&x->x_obj, &x->f_thresh);
+ x->f_hasc = outlet_new(&x->x_obj, gensym("float"));
+ x->f_levs = outlet_new(&x->x_obj, gensym("float"));
+ return (void *)x;
+}
+
+
+void hasc_tilde_setup(void)
+{
+ hasc_tilde_class = class_new(gensym("hasc~"),
+ (t_newmethod)hasc_tilde_new,
+ 0, sizeof(t_hasc_tilde),
+ CLASS_DEFAULT, A_DEFFLOAT, 0);
+
+ post("|===============hasc~=================|");
+ post("|=highest absolute spectral component=|");
+ post("|=====edward======kelly======2005=====|");
+
+ class_addmethod(hasc_tilde_class, (t_method)hasc_tilde_dsp,
+ gensym("dsp"), 0);
+ class_sethelpsymbol(hasc_tilde_class, gensym("help-hasc~"));
+ CLASS_MAINSIGNALIN(hasc_tilde_class, t_hasc_tilde, f);
+}
diff --git a/hasc~/makefile b/hasc~/makefile
new file mode 100644
index 0000000..3780b21
--- /dev/null
+++ b/hasc~/makefile
@@ -0,0 +1,103 @@
+current:
+ echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin
+
+clean: ; rm -f *.pd_* *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: hasc~.dll
+
+.SUFFIXES: .obj .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="D:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I\tcl\include /I..\..\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ ..\..\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:hasc_tilde_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: hasc~.pd_irix5
+
+INSTALL_PREFIX=/usr/local
+EXT=pd_irix5
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I/usr/local/include
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix6: hasc~.pd_irix6
+
+INSTALL_PREFIX=/usr/local
+EXT=pd_irix6
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I/usr/local/include
+
+.c.pd_irix6:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: hasc~.pd_linux
+
+INSTALL_PREFIX=/usr/local
+EXT=pd_linux
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXINCLUDE = -I/usr/local/include
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm $*.o
+
+# ----------------------- Mac OSX -----------------------
+
+pd_darwin: hasc~.pd_darwin
+
+INSTALL_PREFIX=/usr/local
+EXT=pd_darwin
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+.c.pd_darwin:
+ cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o
+
+# ----------------------------------------------
+
+install::
+ install -d $(INSTALL_PREFIX)/lib/pd/extra
+# install -m 644 *.$(EXT) $(INSTALL_PREFIX)/lib/pd/externs
+ -install -m 644 hasc~.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra
+ install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference