aboutsummaryrefslogtreecommitdiff
path: root/externals/extra
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-18 16:43:02 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-18 16:43:02 +0000
commit0a700207f56f18a7bd95f9e2928cd08ee3d8e50a (patch)
tree5f9c829f7611dc24ffe656c21aa794889dba78d8 /externals/extra
parentdc452a6766a4127a3b20fef44f3b1de5fe5a660a (diff)
copied update from 0.43.0test4
svn path=/trunk/; revision=14751
Diffstat (limited to 'externals/extra')
-rw-r--r--externals/extra/bonk~/bonk~-help.pd4
-rw-r--r--externals/extra/bonk~/bonk~.c32
-rw-r--r--externals/extra/choice/choice.c2
-rw-r--r--externals/extra/expr~/vexp.c2
-rw-r--r--externals/extra/expr~/vexp.h6
-rw-r--r--externals/extra/expr~/vexp_fun.c10
-rw-r--r--externals/extra/expr~/vexp_if.c4
-rw-r--r--externals/extra/fiddle~/fiddle~.c10
-rw-r--r--externals/extra/loop~/loop~-help.pd22
-rw-r--r--externals/extra/loop~/loop~.c26
-rw-r--r--externals/extra/lrshift~/lrshift~.c8
-rw-r--r--externals/extra/pd~/pd~.c9
-rw-r--r--externals/extra/pique/pique.c45
-rw-r--r--externals/extra/sigmund~/sigmund~.c69
14 files changed, 147 insertions, 102 deletions
diff --git a/externals/extra/bonk~/bonk~-help.pd b/externals/extra/bonk~/bonk~-help.pd
index e52b7c50..4666d6f5 100644
--- a/externals/extra/bonk~/bonk~-help.pd
+++ b/externals/extra/bonk~/bonk~-help.pd
@@ -1,4 +1,4 @@
-#N canvas 43 123 1054 583 12;
+#N canvas 0 0 1052 581 12;
#X obj 382 492 spigot;
#X msg 484 293 bang;
#X obj 483 454 bonk~;
@@ -107,7 +107,7 @@ Bonk check the attack against a collection of stored templates to try
to guess which of two or more instruments was hit. Bonk is described
theoretically in the 1998 ICMC proceedings \, reprinted on crca.ucsd.edu/~msp
.;
-#N canvas 723 241 701 719 creation-arguments 0;
+#N canvas 0 0 699 717 creation-arguments 1;
#X text 228 14 creation arguments for bonk~;
#X text 70 272 -npts 256;
#X text 44 244 default value:;
diff --git a/externals/extra/bonk~/bonk~.c b/externals/extra/bonk~/bonk~.c
index 6776b2e2..7aaf48da 100644
--- a/externals/extra/bonk~/bonk~.c
+++ b/externals/extra/bonk~/bonk~.c
@@ -53,7 +53,8 @@ decay and other times in msec
#include <stdio.h>
#include <string.h>
-#ifdef NT
+/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans@at.or.at> */
+#ifdef _MSC_VER
#pragma warning (disable: 4305 4244)
#endif
@@ -81,7 +82,9 @@ void *bonk_class;
static t_class *bonk_class;
#endif
-#ifndef _MSC_VER
+#ifdef _WIN32
+#include <malloc.h>
+#elif ! defined(_MSC_VER)
#include <alloca.h>
#endif
@@ -220,6 +223,8 @@ typedef struct _bonk
double x_learndebounce; /* debounce time (in "learn" mode only) */
int x_attackbins; /* number of bins to wait for attack */
+ t_canvas *x_canvas; /* ptr to current canvas --fbar */
+
t_filterbank *x_filterbank;
t_hist x_hist[MAXNFILTERS];
t_template *x_template;
@@ -961,11 +966,18 @@ static void bonk_bang(t_bonk *x)
static void bonk_read(t_bonk *x, t_symbol *s)
{
- FILE *fd = fopen(s->s_name, "r");
float vec[MAXNFILTERS];
int i, ntemplate = 0, remaining;
float *fp, *fp2;
- if (!fd)
+
+ /* fbar: canvas_open code taken from g_array.c */
+ FILE *fd;
+ char buf[MAXPDSTRING], *bufptr;
+ int filedesc;
+
+ if ((filedesc = canvas_open(x->x_canvas,
+ s->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0
+ || !(fd = fdopen(filedesc, "r")))
{
post("%s: open failed", s->s_name);
return;
@@ -1000,11 +1012,18 @@ nomore:
static void bonk_write(t_bonk *x, t_symbol *s)
{
- FILE *fd = fopen(s->s_name, "w");
+ FILE *fd;
+ char buf[MAXPDSTRING]; /* fbar */
int i, ntemplate = x->x_ntemplate;
t_template *tp = x->x_template;
float *fp;
- if (!fd)
+
+ /* fbar: canvas-code as in g_array.c */
+ canvas_makefilename(x->x_canvas, s->s_name,
+ buf, MAXPDSTRING);
+ sys_bashfilename(buf, buf);
+
+ if (!(fd = fopen(buf, "w")))
{
post("%s: couldn't create", s->s_name);
return;
@@ -1047,6 +1066,7 @@ static void *bonk_new(t_symbol *s, int argc, t_atom *argv)
firstbin = DEFFIRSTBIN, minbandwidth = DEFMINBANDWIDTH;
t_insig *g;
+ x->x_canvas = canvas_getcurrent(); /* fbar: bind current canvas to x */
if (argc > 0 && argv[0].a_type == A_FLOAT)
{
/* old style args for compatibility */
diff --git a/externals/extra/choice/choice.c b/externals/extra/choice/choice.c
index b7bf23ab..a50c66ac 100644
--- a/externals/extra/choice/choice.c
+++ b/externals/extra/choice/choice.c
@@ -18,7 +18,7 @@ static t_class *choice_class;
typedef struct _elem
{
float e_age;
- float e_weight[DIMENSION];
+ t_float e_weight[DIMENSION];
} t_elem;
typedef struct _choice
diff --git a/externals/extra/expr~/vexp.c b/externals/extra/expr~/vexp.c
index 7d4d7b52..732944de 100644
--- a/externals/extra/expr~/vexp.c
+++ b/externals/extra/expr~/vexp.c
@@ -2137,6 +2137,6 @@ ex_print(struct ex_ex *eptr)
post("\n");
}
-#ifdef NT
+#ifdef _WIN32
void ABORT( void) {bug("expr");}
#endif
diff --git a/externals/extra/expr~/vexp.h b/externals/extra/expr~/vexp.h
index 92dfb06e..d096842f 100644
--- a/externals/extra/expr~/vexp.h
+++ b/externals/extra/expr~/vexp.h
@@ -236,9 +236,13 @@ extern void ex_store(t_expr *expr, long int argc, struct ex_ex *argv,
int value_getonly(t_symbol *s, t_float *f);
-#ifdef NT
+
+/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans@at.or.at> */
+#ifdef _MSC_VER
#pragma warning (disable: 4305 4244)
+#endif
+#ifdef _WIN32
#define abort ABORT
void ABORT(void);
#endif
diff --git a/externals/extra/expr~/vexp_fun.c b/externals/extra/expr~/vexp_fun.c
index fba49b18..26b0b767 100644
--- a/externals/extra/expr~/vexp_fun.c
+++ b/externals/extra/expr~/vexp_fun.c
@@ -123,7 +123,7 @@ static void ex_if(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *opt
static void ex_ldexp(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
static void ex_imodf(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
static void ex_modf(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
-#ifndef NT
+#ifndef _WIN32
static void ex_cbrt(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
static void ex_erf(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
static void ex_erfc(t_expr *expr, long argc, struct ex_ex *argv, struct ex_ex *optr);
@@ -176,7 +176,7 @@ t_ex_func ex_funcs[] = {
{"ldexp ", ex_ldexp, 1},
{"imodf ", ex_imodf, 1},
{"modf", ex_modf, 1},
-#ifndef NT
+#ifndef _WIN32
{"cbrt", ex_cbrt, 1},
{"erf", ex_erf, 1},
{"erfc", ex_erfc, 1},
@@ -542,7 +542,7 @@ ex_toint(t_expr *e, long int argc, struct ex_ex *argv, struct ex_ex *optr)
FUNC_EVAL_UNARY(left, toint, (int), optr, 0);
}
-#ifdef NT
+#ifdef _WIN32
/* No rint in NT land ??? */
double rint(double x);
@@ -874,7 +874,7 @@ ex_tanh(t_expr *e, long int argc, struct ex_ex *argv, struct ex_ex *optr)
}
-#ifndef NT
+#ifndef _WIN32
static void
ex_asinh(t_expr *e, long argc, struct ex_ex *argv, struct ex_ex *optr)
{
@@ -1239,7 +1239,7 @@ FUNC_DEF_UNARY(ex_modf, fracmodf, (double), 1);
*/
FUNC_DEF(ex_ldexp, ldexp, (double), (int), 1);
-#ifndef NT
+#ifndef _WIN32
/*
* ex_cbrt - cube root
*/
diff --git a/externals/extra/expr~/vexp_if.c b/externals/extra/expr~/vexp_if.c
index 648aba73..aaaf4ef3 100644
--- a/externals/extra/expr~/vexp_if.c
+++ b/externals/extra/expr~/vexp_if.c
@@ -381,7 +381,7 @@ SDY the following coredumps why?
post("expr: internal error expr_new");
default:
pd_error(x, "expr: bad type (%lx) inlet = %d\n",
- eptr->ex_type, i + 1, 0, 0, 0);
+ eptr->ex_type, i + 1);
break;
}
}
@@ -955,7 +955,7 @@ if (!sym || !(garray = (t_garray *)pd_findbyclass(sym, garray_class)) || \
!garray_getfloatwords(garray, &size, &vec)) { \
optr->ex_type = ET_FLT; \
optr->ex_int = 0; \
- error("no such table '%s'", sym->s_name); \
+ error("no such table '%s'", sym?(sym->s_name):"(null)"); \
return; \
}
diff --git a/externals/extra/fiddle~/fiddle~.c b/externals/extra/fiddle~/fiddle~.c
index d959b00f..4633b3c0 100644
--- a/externals/extra/fiddle~/fiddle~.c
+++ b/externals/extra/fiddle~/fiddle~.c
@@ -28,11 +28,17 @@
*
*/
-#ifdef NT
+
+/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans@at.or.at> */
+#ifdef _MSC_VER
+#pragma warning (disable: 4305 4244)
+#endif
+
+/* this #ifdef does nothing, but its there... */
+#ifdef _WIN32
#define flog log
#define fexp exp
#define fsqrt sqrt
-#pragma warning (disable: 4305 4244)
#else
#define flog log
#define fexp exp
diff --git a/externals/extra/loop~/loop~-help.pd b/externals/extra/loop~/loop~-help.pd
index a445b805..ff3d3a63 100644
--- a/externals/extra/loop~/loop~-help.pd
+++ b/externals/extra/loop~/loop~-help.pd
@@ -1,4 +1,4 @@
-#N canvas 33 0 647 662 12;
+#N canvas 234 90 647 662 12;
#X floatatom 41 204 0 0 0 0 - - -;
#X obj 254 382 print~;
#X msg 254 347 bang;
@@ -7,7 +7,7 @@
#X msg 55 252 bang;
#X obj 183 382 print~;
#X msg 183 347 bang;
-#N canvas 0 0 450 300 graph1 0;
+#N canvas 0 0 450 300 (subpatch) 0;
#X array array2 150000 float 0;
#X coords 0 1 150000 -1 200 150 1;
#X restore 393 464 graph;
@@ -22,7 +22,6 @@
#X floatatom 96 303 0 0 0 0 - - -;
#X obj 96 326 *~ 1000;
#X msg 43 568 read ../doc/sound/bell.aiff array2;
-#X msg 43 591 read ../doc/sound/vocal.aiff array2;
#X msg 47 229 set 0.5;
#X text 95 196 left signal input is transposition (1 is normal \, 2
is up an octave \, etc);
@@ -46,6 +45,7 @@ that changing window size doesn't change the transposition.;
to zero--you should mute the output before doing so. This may be desirable
if you've set a large window size but then want to decrease it without
waiting for the next phase crossing.;
+#X msg 43 591 read ../doc/sound/voice.wav array2;
#X connect 0 0 3 0;
#X connect 2 0 1 0;
#X connect 3 0 6 0;
@@ -56,7 +56,7 @@ waiting for the next phase crossing.;
#X connect 4 0 3 1;
#X connect 5 0 3 0;
#X connect 7 0 6 0;
-#X connect 11 0 28 0;
+#X connect 11 0 27 0;
#X connect 12 0 16 0;
#X connect 14 0 13 0;
#X connect 14 0 13 1;
@@ -65,10 +65,10 @@ waiting for the next phase crossing.;
#X connect 17 0 18 0;
#X connect 18 0 15 0;
#X connect 19 0 10 0;
-#X connect 20 0 10 0;
-#X connect 21 0 3 0;
-#X connect 28 0 14 0;
-#X connect 29 0 31 0;
-#X connect 30 0 28 1;
-#X connect 31 0 32 0;
-#X connect 32 0 30 0;
+#X connect 20 0 3 0;
+#X connect 27 0 14 0;
+#X connect 28 0 30 0;
+#X connect 29 0 27 1;
+#X connect 30 0 31 0;
+#X connect 31 0 29 0;
+#X connect 36 0 10 0;
diff --git a/externals/extra/loop~/loop~.c b/externals/extra/loop~/loop~.c
index 2f440030..2fc3193e 100644
--- a/externals/extra/loop~/loop~.c
+++ b/externals/extra/loop~/loop~.c
@@ -13,20 +13,24 @@ This file is downloadable from http://www.crca.ucsd.edu/~msp .
#ifdef PD
#include "m_pd.h"
+#else
+#define t_sample float
#endif
+
+
typedef struct _loopctl
{
double l_phase;
- float l_invwindow;
- float l_window;
+ t_sample l_invwindow;
+ t_sample l_window;
int l_resync;
} t_loopctl;
-static void loopctl_run(t_loopctl *x, float *transposein,
- float *windowin, float *rawout, float *windowout, int n)
+static void loopctl_run(t_loopctl *x, t_sample *transposein,
+ t_sample *windowin, t_sample *rawout, t_sample *windowout, int n)
{
- float window, invwindow;
+ t_sample window, invwindow;
double phase = x->l_phase;
if (x->l_resync)
{
@@ -55,7 +59,7 @@ static void loopctl_run(t_loopctl *x, float *transposein,
{
double phaseinc = invwindow * *transposein++;
double newphase;
- float nwind = *windowin++;
+ t_sample nwind = *windowin++;
if (phaseinc >= 1 || phaseinc < 0)
phaseinc = 0;
newphase = phase + phaseinc;
@@ -77,7 +81,7 @@ static void loopctl_run(t_loopctl *x, float *transposein,
newphase -= 1.;
}
phase = newphase;
- *rawout++ = (float)phase;
+ *rawout++ = (t_sample)phase;
*windowout++ = window;
}
x->l_invwindow = invwindow;
@@ -124,10 +128,10 @@ static void *loop_new(void)
static t_int *loop_perform(t_int *w)
{
t_loopctl *ctl = (t_loopctl *)(w[1]);
- t_float *in1 = (t_float *)(w[2]);
- t_float *in2 = (t_float *)(w[3]);
- t_float *out1 = (t_float *)(w[4]);
- t_float *out2 = (t_float *)(w[5]);
+ t_sample *in1 = (t_sample *)(w[2]);
+ t_sample *in2 = (t_sample *)(w[3]);
+ t_sample *out1 = (t_sample *)(w[4]);
+ t_sample *out2 = (t_sample *)(w[5]);
int n = (int)(w[6]);
loopctl_run(ctl, in1, in2, out1, out2, n);
return (w+7);
diff --git a/externals/extra/lrshift~/lrshift~.c b/externals/extra/lrshift~/lrshift~.c
index 166facc1..b3c90ff6 100644
--- a/externals/extra/lrshift~/lrshift~.c
+++ b/externals/extra/lrshift~/lrshift~.c
@@ -13,8 +13,8 @@ typedef struct _lrshift_tilde
static t_int *leftshift_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out= (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out= (t_sample *)(w[2]);
int n = (int)(w[3]);
int shift = (int)(w[4]);
in += shift;
@@ -28,8 +28,8 @@ static t_int *leftshift_perform(t_int *w)
static t_int *rightshift_perform(t_int *w)
{
- t_float *in = (t_float *)(w[1]);
- t_float *out= (t_float *)(w[2]);
+ t_sample *in = (t_sample *)(w[1]);
+ t_sample *out= (t_sample *)(w[2]);
int n = (int)(w[3]);
int shift = (int)(w[4]);
n -= shift;
diff --git a/externals/extra/pd~/pd~.c b/externals/extra/pd~/pd~.c
index 165065f8..dc2eca4c 100644
--- a/externals/extra/pd~/pd~.c
+++ b/externals/extra/pd~/pd~.c
@@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
-#ifdef NT
+#ifdef _MSC_VER
#pragma warning (disable: 4305 4244)
#endif
@@ -47,7 +47,7 @@ char *class_gethelpdir(t_class *c);
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
#ifdef __x86_64__
static char pd_tilde_dllextent[] = ".l_ia64",
pd_tilde_dllextent2[] = ".pd_linux";
@@ -60,6 +60,9 @@ static char pd_tilde_dllextent[] = ".l_i386",
static char pd_tilde_dllextent[] = ".d_fat",
pd_tilde_dllextent2[] = ".pd_darwin";
#endif
+#if defined(_WIN32) || defined(__CYGWIN__)
+static char pd_tilde_dllextent[] = ".m_i386", pd_tilde_dllextent2[] = ".dll";
+#endif
/* ------------------------ pd_tilde~ ----------------------------- */
@@ -512,7 +515,7 @@ static void *pd_tilde_new(t_symbol *s, int argc, t_atom *argv)
int ninsig = 2, noutsig = 2, j, fifo = 5;
float sr = sys_getsr();
t_sample **g;
- t_symbol *pddir = sys_guidir,
+ t_symbol *pddir = sys_libdir,
*scheddir = gensym(class_gethelpdir(pd_tilde_class));
/* fprintf(stderr, "pd %s, sched %s\n", pddir->s_name, scheddir->s_name); */
while (argc > 0)
diff --git a/externals/extra/pique/pique.c b/externals/extra/pique/pique.c
index f4cae5e1..19cee2ae 100644
--- a/externals/extra/pique/pique.c
+++ b/externals/extra/pique/pique.c
@@ -7,7 +7,8 @@ combustible materiel, or as part of any life support system or weapon. */
#include "m_pd.h"
#include <math.h>
#include <stdio.h>
-#ifdef NT
+/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans@at.or.at> */
+#ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
@@ -50,7 +51,7 @@ static float hanning(float pidetune, float sinpidetune)
(sinpidetune/(pidetune+pi) + sinpidetune/(pidetune-pi)));
}
-static float peakerror(float *fpreal, float *fpimag, float pidetune,
+static float peakerror(t_word *fpreal, t_word *fpimag, float pidetune,
float norm, float peakreal, float peakimag)
{
float sinpidetune = sin(pidetune);
@@ -60,8 +61,10 @@ static float peakerror(float *fpreal, float *fpimag, float pidetune,
peakreal * cospidetune + peakimag * sinpidetune);
float imagshould = windowshould * (
peakimag * cospidetune - peakreal * sinpidetune);
- float realgot = norm * (fpreal[0] - 0.5 * (fpreal[1] + fpreal[-1]));
- float imaggot = norm * (fpimag[0] - 0.5 * (fpimag[1] + fpimag[-1]));
+ float realgot = norm * (fpreal[0].w_float -
+ 0.5 * (fpreal[1].w_float + fpreal[-1].w_float));
+ float imaggot = norm * (fpimag[0].w_float -
+ 0.5 * (fpimag[1].w_float + fpimag[-1].w_float));
float realdev = realshould - realgot, imagdev = imagshould - imaggot;
/* post("real %f->%f; imag %f->%f", realshould, realgot,
@@ -69,7 +72,7 @@ static float peakerror(float *fpreal, float *fpimag, float pidetune,
return (realdev * realdev + imagdev * imagdev);
}
-static void pique_doit(int npts, t_float *fpreal, t_float *fpimag,
+static void pique_doit(int npts, t_word *fpreal, t_word *fpimag,
int npeak, int *nfound, t_float *fpfreq, t_float *fpamp,
t_float *fpampre, t_float *fpampim, float errthresh)
{
@@ -77,13 +80,15 @@ static void pique_doit(int npts, t_float *fpreal, t_float *fpimag,
float oneovern = 1.0/ (float)npts;
float fperbin = srate * oneovern;
float pow1, pow2 = 0, pow3 = 0, pow4 = 0, pow5 = 0;
- float re1, re2 = 0, re3 = *fpreal;
+ float re1, re2 = 0, re3 = fpreal->w_float;
float im1, im2 = 0, im3 = 0, powthresh, relativeerror;
int count, peakcount = 0, n2 = (npts >> 1);
float *fp1, *fp2;
- for (count = n2, fp1 = fpreal, fp2 = fpimag, powthresh = 0;
- count--; fp1++, fp2++)
- powthresh += (*fp1) * (*fp1) + (*fp2) * (*fp2) ;
+ t_word *wp1, *wp2;
+ for (count = n2, wp1 = fpreal, wp2 = fpimag, powthresh = 0;
+ count--; wp1++, wp2++)
+ powthresh += (wp1->w_float) * (wp1->w_float) +
+ (wp2->w_float) * (wp2->w_float) ;
powthresh *= 0.00001;
for (count = 1; count < n2; count++)
{
@@ -97,10 +102,10 @@ static void pique_doit(int npts, t_float *fpreal, t_float *fpimag,
fpimag++;
re1 = re2;
re2 = re3;
- re3 = *fpreal;
+ re3 = fpreal->w_float;
im1 = im2;
im2 = im3;
- im3 = *fpimag;
+ im3 = fpimag->w_float;
if (count < 2) continue;
pow1 = pow2;
pow2 = pow3;
@@ -117,12 +122,12 @@ static void pique_doit(int npts, t_float *fpreal, t_float *fpimag,
|| pow3 < powthresh)
continue;
/* go back for the raw FFT values around the peak. */
- rpeak = fpreal[-3];
- rpeaknext = fpreal[-2];
- rpeakprev = fpreal[-4];
- ipeak = fpimag[-3];
- ipeaknext = fpimag[-2];
- ipeakprev = fpimag[-4];
+ rpeak = fpreal[-3].w_float;
+ rpeaknext = fpreal[-2].w_float;
+ rpeakprev = fpreal[-4].w_float;
+ ipeak = fpimag[-3].w_float;
+ ipeaknext = fpimag[-2].w_float;
+ ipeakprev = fpimag[-4].w_float;
/* recalculate Hanning-windowed spectrum by convolution */
windreal = rpeak - 0.5 * (rpeaknext + rpeakprev);
windimag = ipeak - 0.5 * (ipeaknext + ipeakprev);
@@ -179,15 +184,15 @@ static void pique_list(t_pique *x, t_symbol *s, int argc, t_atom *argv)
int npeak = atom_getintarg(3, argc, argv);
int n;
t_garray *a;
- t_float *fpreal, *fpimag;
+ t_word *fpreal, *fpimag;
if (npts < 8 || npeak < 1) error("pique: bad npoints or npeak");
if (npeak > x->x_n) npeak = x->x_n;
if (!(a = (t_garray *)pd_findbyclass(symreal, garray_class)) ||
- !garray_getfloatarray(a, &n, &fpreal) ||
+ !garray_getfloatwords(a, &n, &fpreal) ||
n < npts)
error("%s: missing or bad array", symreal->s_name);
else if (!(a = (t_garray *)pd_findbyclass(symimag, garray_class)) ||
- !garray_getfloatarray(a, &n, &fpimag) ||
+ !garray_getfloatwords(a, &n, &fpimag) ||
n < npts)
error("%s: missing or bad array", symimag->s_name);
else
diff --git a/externals/extra/sigmund~/sigmund~.c b/externals/extra/sigmund~/sigmund~.c
index 0f8b9283..968c5c63 100644
--- a/externals/extra/sigmund~/sigmund~.c
+++ b/externals/extra/sigmund~/sigmund~.c
@@ -13,7 +13,7 @@
and usable in other contexts. The one external requirement is a real
single-precision FFT, invoked as in the Mayer one: */
-#ifdef NT
+#ifdef _MSC_VER /* this is only needed with Microsoft's compiler */
__declspec(dllimport) extern
#endif
void mayer_realfft(int npoints, float *buf);
@@ -26,13 +26,13 @@ for example, defines this in the file d_fft_mayer.c or d_fft_fftsg.c. */
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef NT
+#ifdef _WIN32
#include <malloc.h>
-#else
+#elif ! defined(_MSC_VER)
#include <alloca.h>
#endif
#include <stdlib.h>
-#ifdef NT
+#ifdef _MSC_VER
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
@@ -230,19 +230,21 @@ static void sigmund_remask(int maxbin, int bestindex, float powmask,
}
}
+#define PEAKMASKFACTOR 1.
+#define PEAKTHRESHFACTOR 0.6
+
static void sigmund_getrawpeaks(int npts, float *insamps,
int npeak, t_peak *peakv, int *nfound, float *power, float srate, int loud,
- float param1, float param2, float param3, float hifreq)
+ float hifreq)
{
float oneovern = 1.0/ (float)npts;
- float fperbin = 0.5 * srate * oneovern;
+ float fperbin = 0.5 * srate * oneovern, totalpower = 0;
int npts2 = 2*npts, i, bin;
int peakcount = 0;
float *fp1, *fp2;
float *rawreal, *rawimag, *maskbuf, *powbuf;
float *bigbuf = alloca(sizeof (float ) * (2*NEGBINS + 6*npts));
int maxbin = hifreq/fperbin;
- int tweak = (param3 == 0);
if (maxbin > npts - NEGBINS)
maxbin = npts - NEGBINS;
/* if (loud) post("tweak %d", tweak); */
@@ -272,16 +274,18 @@ static void sigmund_getrawpeaks(int npts, float *insamps,
rawimag[-3] = -rawimag[3];
rawimag[-4] = -rawimag[4];
#if 1
- for (i = 0, fp1 = rawreal, fp2 = rawimag; i < npts-1; i++, fp1++, fp2++)
+ for (i = 0, fp1 = rawreal, fp2 = rawimag; i < maxbin; i++, fp1++, fp2++)
{
- float x1 = fp1[1] - fp1[-1], x2 = fp2[1] - fp2[-1];
- powbuf[i] = x1*x1+x2*x2;
+ float x1 = fp1[1] - fp1[-1], x2 = fp2[1] - fp2[-1], p = powbuf[i] = x1*x1+x2*x2;
+ if (i >= 2)
+ totalpower += p;
}
- powbuf[npts-1] = 0;
+ powbuf[maxbin] = powbuf[maxbin+1] = 0;
+ *power = 0.5 * totalpower *oneovern * oneovern;
#endif
for (peakcount = 0; peakcount < npeak; peakcount++)
{
- float pow1, maxpower = 0, totalpower = 0, windreal, windimag, windpower,
+ float pow1, maxpower = 0, windreal, windimag, windpower,
detune, pidetune, sinpidetune, cospidetune, ampcorrect, ampout,
ampoutreal, ampoutimag, freqout, powmask;
int bestindex = -1;
@@ -292,19 +296,17 @@ static void sigmund_getrawpeaks(int npts, float *insamps,
pow1 = powbuf[bin];
if (pow1 > maxpower && pow1 > maskbuf[bin])
{
- float thresh = param2 * (powbuf[bin-2]+powbuf[bin+2]);
+ float thresh = PEAKTHRESHFACTOR * (powbuf[bin-2]+powbuf[bin+2]);
if (pow1 > thresh)
maxpower = pow1, bestindex = bin;
}
- totalpower += pow1;
}
if (totalpower <= 0 || maxpower < 1e-10*totalpower || bestindex < 0)
break;
fp1 = rawreal+bestindex;
fp2 = rawimag+bestindex;
- *power = 0.5 * totalpower *oneovern * oneovern;
- powmask = maxpower * exp(-param1 * log(10.) / 10.);
+ powmask = maxpower * PEAKMASKFACTOR;
/* if (loud > 2)
post("maxpower %f, powmask %f, param1 %f",
maxpower, powmask, param1); */
@@ -344,11 +346,8 @@ static void sigmund_getrawpeaks(int npts, float *insamps,
peakv[peakcount].p_ampreal = oneovern * ampoutreal;
peakv[peakcount].p_ampimag = oneovern * ampoutimag;
}
- if (tweak)
- {
- sigmund_tweak(npts, rawreal, rawimag, peakcount, peakv, fperbin, loud);
- sigmund_tweak(npts, rawreal, rawimag, peakcount, peakv, fperbin, loud);
- }
+ sigmund_tweak(npts, rawreal, rawimag, peakcount, peakv, fperbin, loud);
+ sigmund_tweak(npts, rawreal, rawimag, peakcount, peakv, fperbin, loud);
for (i = 0; i < peakcount; i++)
{
peakv[i].p_pit = sigmund_ftom(peakv[i].p_freq);
@@ -360,13 +359,12 @@ static void sigmund_getrawpeaks(int npts, float *insamps,
/*************** Routines for finding fundamental pitch *************/
#define PITCHNPEAK 12
-#define PITCHUNCERTAINTY 0.3
#define HALFTONEINC 0.059
#define SUBHARMONICS 16
#define DBPERHALFTONE 0.0
static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
- float npts, float srate, int loud)
+ float npts, float srate, float nharmonics, float amppower, int loud)
{
float fperbin = 0.5 * srate / npts;
int npit = 48 * sigmund_ilog2(npts), i, j, k, nsalient;
@@ -407,7 +405,7 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
t_peak *thispeak = bigpeaks[i];
float weightindex = (48./LOG2) *
log(thispeak->p_freq/(2.*fperbin));
- float loudness = sqrt(thispeak->p_amp);
+ float loudness = pow(thispeak->p_amp, amppower);
/* post("index %f, uncertainty %f", weightindex, pitchuncertainty); */
for (j = 0; j < SUBHARMONICS; j++)
{
@@ -422,7 +420,7 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
if (loindex < 0)
loindex = 0;
for (k = loindex; k <= hiindex; k++)
- weights[k] += loudness * 6. / (6. + j);
+ weights[k] += loudness * nharmonics / (nharmonics + j);
}
sumweight += loudness;
}
@@ -860,8 +858,8 @@ typedef struct _sigmund
static void sigmund_preinit(t_sigmund *x)
{
x->x_npts = NPOINTS_DEF;
- x->x_param1 = 0;
- x->x_param2 = 0.6;
+ x->x_param1 = 6;
+ x->x_param2 = 0.5;
x->x_param3 = 0;
x->x_hop = HOP_DEF;
x->x_mode = MODE_STREAM;
@@ -977,10 +975,10 @@ static void sigmund_doit(t_sigmund *x, int npts, float *arraypoints,
int nfound, i, cnt;
float freq = 0, power, note = 0;
sigmund_getrawpeaks(npts, arraypoints, x->x_npeak, peakv,
- &nfound, &power, srate, loud, x->x_param1, x->x_param2, x->x_param3,
- x->x_maxfreq);
+ &nfound, &power, srate, loud, x->x_maxfreq);
if (x->x_dopitch)
- sigmund_getpitch(nfound, peakv, &freq, npts, srate, loud);
+ sigmund_getpitch(nfound, peakv, &freq, npts, srate,
+ x->x_param1, x->x_param2, loud);
if (x->x_donote)
notefinder_doit(&x->x_notefinder, freq, power, &note, x->x_vibrato,
1 + x->x_stabletime * 0.001f * x->x_sr / (float)x->x_hop,
@@ -1054,6 +1052,7 @@ static void sigmund_print(t_sigmund *x)
post("stabletime %g", x->x_stabletime);
post("growth %g", x->x_growth);
post("minpower %g", x->x_minpower);
+ x->x_loud = 1;
}
static void sigmund_free(t_sigmund *x)
@@ -1111,7 +1110,7 @@ static void sigmund_tick(t_sigmund *x)
static t_int *sigmund_perform(t_int *w)
{
t_sigmund *x = (t_sigmund *)(w[1]);
- float *in = (float *)(w[2]);
+ t_sample *in = (float *)(w[2]);
int n = (int)(w[3]);
if (x->x_hop % n)
@@ -1394,7 +1393,7 @@ void sigmund_tilde_setup(void)
gensym("print"), 0);
class_addmethod(sigmund_class, (t_method)sigmund_printnext,
gensym("printnext"), A_FLOAT, 0);
- post("sigmund~ version 0.05");
+ post("sigmund~ version 0.07");
}
#endif /* PD */
@@ -1428,6 +1427,10 @@ static t_int *sigmund_perform(t_int *w)
int n = (int)(w[3]), j;
int infill = x->x_infill;
float *fp = x->x_inbuf2 + infill;
+
+ if (x->x_obj.z_disabled) /* return if in muted MSP subpatch -Rd */
+ return (w+4);
+
if (infill < 0 || infill >= x->x_npts)
infill = 0;
/* for some reason this sometimes happens: */
@@ -1641,7 +1644,7 @@ int main()
class_register(CLASS_BOX, c);
sigmund_class = c;
- post("sigmund~ v0.05");
+ post("sigmund~ version 0.07");
return (0);
}