diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-01-18 16:43:02 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-01-18 16:43:02 +0000 |
commit | 0a700207f56f18a7bd95f9e2928cd08ee3d8e50a (patch) | |
tree | 5f9c829f7611dc24ffe656c21aa794889dba78d8 /externals/extra/bonk~ | |
parent | dc452a6766a4127a3b20fef44f3b1de5fe5a660a (diff) |
copied update from 0.43.0test4
svn path=/trunk/; revision=14751
Diffstat (limited to 'externals/extra/bonk~')
-rw-r--r-- | externals/extra/bonk~/bonk~-help.pd | 4 | ||||
-rw-r--r-- | externals/extra/bonk~/bonk~.c | 32 |
2 files changed, 28 insertions, 8 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 */ |