From 0a700207f56f18a7bd95f9e2928cd08ee3d8e50a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 18 Jan 2011 16:43:02 +0000 Subject: copied update from 0.43.0test4 svn path=/trunk/; revision=14751 --- externals/extra/bonk~/bonk~-help.pd | 4 ++-- externals/extra/bonk~/bonk~.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'externals/extra/bonk~') 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 #include -#ifdef NT +/* These pragmas are only used for MSVC, not MinGW or Cygwin */ +#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 +#elif ! defined(_MSC_VER) #include #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 */ -- cgit v1.2.1