diff options
author | N.N. <krzyszcz@users.sourceforge.net> | 2005-01-11 10:33:23 +0000 |
---|---|---|
committer | N.N. <krzyszcz@users.sourceforge.net> | 2005-01-11 10:33:23 +0000 |
commit | 6435314717c5fb8fa062eb682c72c8df095b1be3 (patch) | |
tree | 484d02446358890397a755fc144d4ecf25b38f2d /cyclone/hammer | |
parent | b89456a346e176c4dc536e7de8f14b152cb2b15b (diff) |
svf~: args parsing; prepend/Append: bang handling; seq: pause, continue, goto; many maxmode changes
svn path=/trunk/externals/miXed/; revision=2490
Diffstat (limited to 'cyclone/hammer')
-rw-r--r-- | cyclone/hammer/Append.c | 63 | ||||
-rw-r--r-- | cyclone/hammer/Decode.c | 7 | ||||
-rw-r--r-- | cyclone/hammer/Makefile.objects | 1 | ||||
-rw-r--r-- | cyclone/hammer/Table.c | 4 | ||||
-rw-r--r-- | cyclone/hammer/bangbang.c | 9 | ||||
-rw-r--r-- | cyclone/hammer/coll.c | 54 | ||||
-rw-r--r-- | cyclone/hammer/comment.c | 34 | ||||
-rw-r--r-- | cyclone/hammer/counter.c | 18 | ||||
-rw-r--r-- | cyclone/hammer/cycle.c | 7 | ||||
-rw-r--r-- | cyclone/hammer/funbuff.c | 4 | ||||
-rw-r--r-- | cyclone/hammer/gate.c | 9 | ||||
-rw-r--r-- | cyclone/hammer/hammer.c | 30 | ||||
-rw-r--r-- | cyclone/hammer/maximum.c | 7 | ||||
-rw-r--r-- | cyclone/hammer/minimum.c | 7 | ||||
-rw-r--r-- | cyclone/hammer/mtr.c | 26 | ||||
-rw-r--r-- | cyclone/hammer/past.c | 7 | ||||
-rw-r--r-- | cyclone/hammer/prepend.c | 38 | ||||
-rw-r--r-- | cyclone/hammer/prob.c | 11 | ||||
-rw-r--r-- | cyclone/hammer/pv.c | 18 | ||||
-rw-r--r-- | cyclone/hammer/seq.c | 125 | ||||
-rw-r--r-- | cyclone/hammer/sprintf.c | 14 | ||||
-rw-r--r-- | cyclone/hammer/switch.c | 9 | ||||
-rw-r--r-- | cyclone/hammer/tosymbol.c | 5 | ||||
-rw-r--r-- | cyclone/hammer/urn.c | 9 | ||||
-rw-r--r-- | cyclone/hammer/zl.c | 24 |
25 files changed, 347 insertions, 193 deletions
diff --git a/cyclone/hammer/Append.c b/cyclone/hammer/Append.c index ad615d5..16b65cc 100644 --- a/cyclone/hammer/Append.c +++ b/cyclone/hammer/Append.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -6,6 +6,7 @@ #include "m_pd.h" #include "common/loud.h" #include "common/grow.h" +#include "common/fitter.h" #define APPEND_INISIZE 32 /* LATER rethink */ #define APPEND_MAXSIZE 256 @@ -33,6 +34,9 @@ typedef struct _appendxy static t_class *append_class; static t_class *appendxy_class; +static t_symbol *appendps_compatibility = 0; +static t_symbol *appendps_max; + /* Usually a preallocation method is used, except in special cases of: 1) reentrant output request, or 2) an output request which would cause resizing to more than MAXSIZE (no such limit for a 'set' message). @@ -42,7 +46,8 @@ static t_class *appendxy_class; preallocation method is chosen). Instead, self-invoked 'set' messages are postponed, using an auxiliary buffer. */ -/* Any Append's output goes through outlet_anything() -> typedmess() */ +/* Any Append's output, except bangout, goes through + outlet_anything() -> typedmess(), LATER rethink */ static void append_setnatoms(t_append *x, int natoms) { @@ -50,6 +55,31 @@ static void append_setnatoms(t_append *x, int natoms) x->x_natoms = natoms; } +static void append_bangout(t_outlet *outp, int ac, t_atom *av) +{ + if (ac) + { + if (av->a_type == A_SYMBOL) + outlet_anything(outp, av->a_w.w_symbol, ac-1, av+1); + else if (av->a_type == A_POINTER) + { + if (ac == 1) + outlet_pointer(outp, av->a_w.w_gpointer); + else + outlet_list(outp, &s_list, ac, av); + } + else if (av->a_type == A_FLOAT) + { + if (ac == 1) + outlet_float(outp, av->a_w.w_float); + else + outlet_list(outp, &s_list, ac, av); + } + else loudbug_bug("append_bangout"); + } + else outlet_bang(outp); +} + static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av) { int reentered = x->x_entered; @@ -77,7 +107,10 @@ static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av) buf = x->x_message - ac; if (ac) memcpy(buf, av, ac * sizeof(*buf)); - outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + if (s) + outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + else + append_bangout(((t_object *)x)->ob_outlet, ntotal, buf); } else { @@ -88,7 +121,10 @@ static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av) memcpy(buf, av, ac * sizeof(*buf)); if (x->x_natoms) memcpy(buf + ac, x->x_message, x->x_natoms * sizeof(*buf)); - outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + if (s) + outlet_anything(((t_object *)x)->ob_outlet, s, ntotal, buf); + else + append_bangout(((t_object *)x)->ob_outlet, ntotal, buf); freebytes(buf, ntotal * sizeof(*buf)); } } @@ -119,7 +155,11 @@ static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av) static void append_bang(t_append *x) { - /* CHECKED: a nop */ + if (appendps_compatibility == appendps_max) + { + /* CHECKED: a nop */ + } + else append_anything(x, 0, 0, 0); } static void append_float(t_append *x, t_float f) @@ -203,10 +243,11 @@ static void append_doset(t_append *x, t_symbol *s, int ac, t_atom *av) static void append_set(t_append *x, t_symbol *s, int ac, t_atom *av) { - if (shared_getmaxcompatibility()) - append_doset(x, 0, ac, av); - else + if (x->x_proxy) append_anything(x, s, ac, av); + else + /* LATER (when?) controlled by maxmode */ + append_doset(x, 0, ac, av); } static void appendxy_bang(t_appendxy *xy) @@ -253,7 +294,7 @@ static void append_free(t_append *x) freebytes(x->x_messbuf, x->x_size * sizeof(*x->x_messbuf)); if (x->x_auxbuf) { - bug("append_free"); /* LATER rethink */ + loudbug_bug("append_free"); /* LATER rethink */ freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf)); } if (x->x_proxy) @@ -269,7 +310,6 @@ static void *append_new(t_symbol *s, int ac, t_atom *av) x->x_auxbuf = 0; x->x_entered = 0; append_setnatoms(x, 0); - shared_usecompatibility(); if (ac) { x->x_proxy = 0; @@ -307,4 +347,7 @@ void Append_setup(void) class_addsymbol(appendxy_class, appendxy_symbol); class_addlist(appendxy_class, appendxy_list); class_addanything(appendxy_class, appendxy_anything); + + appendps_max = gensym("max"); + fitter_setup(append_class, &appendps_compatibility, 0); } diff --git a/cyclone/hammer/Decode.c b/cyclone/hammer/Decode.c index 77d8f38..0342594 100644 --- a/cyclone/hammer/Decode.c +++ b/cyclone/hammer/Decode.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -7,6 +7,7 @@ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define DECODE_C74MAXOUTS 8 /* CHECKED (does it make any sense?) */ #define DECODE_DEFOUTS 1 @@ -78,8 +79,7 @@ static void *Decode_new(t_floatarg val) nouts = DECODE_DEFOUTS; if (nouts > DECODE_C74MAXOUTS) { - shared_usecompatibility(); - loud_incompatible_max(Decode_class, DECODE_C74MAXOUTS, "outlets"); + fittermax_rangewarning(Decode_class, DECODE_C74MAXOUTS, "outlets"); if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) return (0); } @@ -108,4 +108,5 @@ void Decode_setup(void) gensym("ft1"), A_FLOAT, 0); class_addmethod(Decode_class, (t_method)Decode_alloff, gensym("ft2"), A_FLOAT, 0); + fitter_setup(Decode_class, 0, 0); } diff --git a/cyclone/hammer/Makefile.objects b/cyclone/hammer/Makefile.objects index 78bff7e..eb54f17 100644 --- a/cyclone/hammer/Makefile.objects +++ b/cyclone/hammer/Makefile.objects @@ -4,6 +4,7 @@ unstable/fragile.o \ unstable/fringe.o \ common/loud.o \ common/grow.o \ +common/fitter.o \ common/rand.o \ common/vefl.o \ common/mifi.o \ diff --git a/cyclone/hammer/Table.c b/cyclone/hammer/Table.c index 66543e3..a120f13 100644 --- a/cyclone/hammer/Table.c +++ b/cyclone/hammer/Table.c @@ -358,7 +358,7 @@ static t_tablecommon *table_checkcommon(t_table *x) x->x_common != (t_tablecommon *)pd_findbyclass(x->x_name, tablecommon_class)) { - bug("table_checkcommon"); + loudbug_bug("table_checkcommon"); return (0); } return (x->x_common); @@ -796,7 +796,7 @@ static void table_debug(t_table *x, t_floatarg f) t_table *x1 = cc->c_refs; int i = 0; while (x1) i++, x1 = x1->x_next; - post("refcount %d", i); + loudbug_post("refcount %d", i); } } #endif diff --git a/cyclone/hammer/bangbang.c b/cyclone/hammer/bangbang.c index d1eb53a..5ae3506 100644 --- a/cyclone/hammer/bangbang.c +++ b/cyclone/hammer/bangbang.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -7,6 +7,7 @@ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define BANGBANG_MINOUTS 1 #define BANGBANG_C74MAXOUTS 40 /* CHECKED (just clipped without warning) */ @@ -47,10 +48,7 @@ static void *bangbang_new(t_floatarg val) if (nouts < BANGBANG_MINOUTS) nouts = BANGBANG_DEFOUTS; if (nouts > BANGBANG_C74MAXOUTS) - { - shared_usecompatibility(); - loud_incompatible_max(bangbang_class, BANGBANG_C74MAXOUTS, "outlets"); - } + fittermax_rangewarning(bangbang_class, BANGBANG_C74MAXOUTS, "outlets"); if (nouts > BANGBANG_DEFOUTS) { if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) @@ -73,4 +71,5 @@ void bangbang_setup(void) sizeof(t_bangbang), 0, A_DEFFLOAT, 0); class_addbang(bangbang_class, bangbang_bang); class_addanything(bangbang_class, bangbang_anything); + fitter_setup(bangbang_class, 0, 0); } diff --git a/cyclone/hammer/coll.c b/cyclone/hammer/coll.c index ee2da0c..a0644c8 100644 --- a/cyclone/hammer/coll.c +++ b/cyclone/hammer/coll.c @@ -143,25 +143,6 @@ static int collelem_less(t_collelem *ep1, t_collelem *ep2, int ndx) } } -static void collelem_post(t_collelem *ep) -{ - if (ep->e_hasnumkey && ep->e_symkey) - startpost("%d %s:", ep->e_numkey, ep->e_symkey->s_name); - else if (ep->e_hasnumkey) - startpost("%d:", ep->e_numkey); - else if (ep->e_symkey) - startpost("%s:", ep->e_symkey->s_name); - else bug("collcommon_post"); - postatom(ep->e_size, ep->e_data); - endpost(); -} - -static void collcommon_post(t_collcommon *cc) -{ - t_collelem *ep; - for (ep = cc->c_first; ep; ep = ep->e_next) collelem_post(ep); -} - static t_collelem *collcommon_numkey(t_collcommon *cc, int numkey) { t_collelem *ep; @@ -294,7 +275,7 @@ static void collcommon_putbefore(t_collcommon *cc, next->e_prev = ep; } else if (cc->c_first || cc->c_last) - bug("collcommon_putbefore"); + loudbug_bug("collcommon_putbefore"); else cc->c_first = cc->c_last = ep; collcommon_modified(cc, 1); @@ -313,7 +294,7 @@ static void collcommon_putafter(t_collcommon *cc, prev->e_next = ep; } else if (cc->c_first || cc->c_last) - bug("collcommon_putafter"); + loudbug_bug("collcommon_putafter"); else cc->c_first = cc->c_last = ep; collcommon_modified(cc, 1); @@ -363,7 +344,7 @@ static void collcommon_swaplinks(t_collcommon *cc, collcommon_putafter(cc, ep1, prev2); collcommon_putbefore(cc, ep2, next1); } - else bug("collcommon_swaplinks"); + else loudbug_bug("collcommon_swaplinks"); } } @@ -780,7 +761,7 @@ static t_collcommon *coll_checkcommon(t_coll *x) x->x_common != (t_collcommon *)pd_findbyclass(x->x_name, collcommon_class)) { - bug("coll_checkcommon"); + loudbug_bug("coll_checkcommon"); return (0); } return (x->x_common); @@ -1237,7 +1218,7 @@ static void coll_next(t_coll *x) if (cc->c_head) coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); else if (!cc->c_selfmodified) - bug("coll_next"); /* LATER rethink */ + loudbug_bug("coll_next"); /* LATER rethink */ } static void coll_prev(t_coll *x) @@ -1257,7 +1238,7 @@ static void coll_prev(t_coll *x) if (cc->c_head) coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); else if (!cc->c_selfmodified) - bug("coll_prev"); /* LATER rethink */ + loudbug_bug("coll_prev"); /* LATER rethink */ } static void coll_end(t_coll *x) @@ -1488,6 +1469,25 @@ static void coll_click(t_coll *x, t_floatarg xpos, t_floatarg ypos, } #ifdef COLL_DEBUG +static void collelem_post(t_collelem *ep) +{ + if (ep->e_hasnumkey && ep->e_symkey) + loudbug_startpost("%d %s:", ep->e_numkey, ep->e_symkey->s_name); + else if (ep->e_hasnumkey) + loudbug_startpost("%d:", ep->e_numkey); + else if (ep->e_symkey) + loudbug_startpost("%s:", ep->e_symkey->s_name); + else loudbug_bug("collcommon_post"); + loudbug_postatom(ep->e_size, ep->e_data); + loudbug_endpost(); +} + +static void collcommon_post(t_collcommon *cc) +{ + t_collelem *ep; + for (ep = cc->c_first; ep; ep = ep->e_next) collelem_post(ep); +} + static void coll_debug(t_coll *x, t_floatarg f) { t_collcommon *cc = coll_checkcommon(x); @@ -1497,9 +1497,9 @@ static void coll_debug(t_coll *x, t_floatarg f) t_collelem *ep, *last; int i = 0; while (x1) i++, x1 = x1->x_next; - post("refcount %d", i); + loudbug_post("refcount %d", i); for (ep = cc->c_first, last = 0; ep; ep = ep->e_next) last = ep; - if (last != cc->c_last) bug("coll_debug: last element"); + if (last != cc->c_last) loudbug_bug("coll_debug: last element"); collcommon_post(cc); } } diff --git a/cyclone/hammer/comment.c b/cyclone/hammer/comment.c index 567c5b1..8f885a6 100644 --- a/cyclone/hammer/comment.c +++ b/cyclone/hammer/comment.c @@ -81,7 +81,7 @@ static void comment_draw(t_comment *x) if (reqsize > COMMENT_OUTBUFSIZE) { #ifdef COMMENT_DEBUG - post("allocating %d outbuf bytes", reqsize); + loudbug_post("allocating %d outbuf bytes", reqsize); #endif if (!(outbuf = getbytes(reqsize))) return; @@ -125,7 +125,7 @@ static void comment_update(t_comment *x) if (reqsize > COMMENT_OUTBUFSIZE) { #ifdef COMMENT_DEBUG - post("allocating %d outbuf bytes", reqsize); + loudbug_post("allocating %d outbuf bytes", reqsize); #endif if (!(outbuf = getbytes(reqsize))) return; @@ -185,14 +185,14 @@ static void comment_validate(t_comment *x, t_glist *glist) binbuf_gettext(x->x_binbuf, &x->x_textbuf, &x->x_textbufsize); x->x_ready = 1; #ifdef COMMENT_DEBUG - post("validation done"); + loudbug_post("validation done"); #endif } if (glist) { if (glist != x->x_glist) { - bug("comment_getcanvas"); + loudbug_bug("comment_getcanvas"); x->x_glist = glist; } x->x_canvas = glist_getcanvas(glist); @@ -203,7 +203,7 @@ static void comment_grabbedkey(void *z, t_floatarg f) { /* LATER think about replacing #key binding/comment_float() with grabbing */ #ifdef COMMENT_DEBUG - post("comment_grabbedkey %g", f); + loudbug_post("comment_grabbedkey %g", f); #endif } @@ -221,7 +221,7 @@ static void comment__bboxhook(t_comment *x, t_symbol *bindsym, t_floatarg x2, t_floatarg y2) { #ifdef COMMENT_DEBUG - post("bbox %g %g %g %g", x1, y1, x2, y2); + loudbug_post("bbox %g %g %g %g", x1, y1, x2, y2); #endif x->x_x1 = x1; x->x_y1 = y1; @@ -249,7 +249,7 @@ static void comment__clickhook(t_comment *x, t_symbol *s, int ac, t_atom *av) } else { - bug("comment__clickhook"); + loudbug_bug("comment__clickhook"); return; } if (x->x_glist->gl_edit) @@ -321,7 +321,7 @@ static void commentsink__bboxhook(t_pd *x, t_symbol *bindsym, { pd_unbind(x, bindsym); /* if so, no need for this binding anymore */ #ifdef COMMENT_DEBUG - post("sink: %s unbound", bindsym->s_name); + loudbug_post("sink: %s unbound", bindsym->s_name); #endif } } @@ -368,7 +368,7 @@ static void comment_getrect(t_gobj *z, t_glist *glist, x2 = x1 + width; y2 = y1 + height - 2; /* LATER revisit */ #ifdef COMMENT_DEBUG - post("estimated rectangle: %g %g %g %g", x1, y1, x2, y2); + loudbug_post("estimated rectangle: %g %g %g %g", x1, y1, x2, y2); #endif *xp1 = x1; *yp1 = y1; @@ -465,7 +465,7 @@ static void comment_vis(t_gobj *z, t_glist *glist, int vis) #endif /* FIXME should we test for having a window? */ #ifdef COMMENT_DEBUG - post("deleting..."); + loudbug_post("deleting..."); #endif sys_vgui(".x%x.c delete %s\n", x->x_canvas, x->x_tag); } @@ -540,7 +540,7 @@ static void comment_float(t_comment *x, t_float f) if (n == '\n' || !iscntrl(n)) { #ifdef COMMENT_DEBUG - post("%d accepted", n); + loudbug_post("%d accepted", n); #endif newsize = x->x_textbufsize+1; x->x_textbuf = resizebytes(x->x_textbuf, @@ -552,7 +552,7 @@ static void comment_float(t_comment *x, t_float f) x->x_selstart = x->x_selstart + 1; } #ifdef COMMENT_DEBUG - else post("%d rejected", n); + else loudbug_post("%d rejected", n); #endif x->x_selend = x->x_selstart; x->x_glist->gl_editor->e_textdirty = 1; @@ -560,17 +560,17 @@ static void comment_float(t_comment *x, t_float f) comment_update(x); } } - else bug("comment_float"); + else loudbug_bug("comment_float"); donefloat:; #ifdef COMMENT_DEBUG - post("donefloat"); + loudbug_post("donefloat"); #endif } static void comment_list(t_comment *x, t_symbol *s, int ac, t_atom *av) { if (!x->x_active) - bug("comment_list"); + loudbug_bug("comment_list"); else if (ac > 1 && av->a_type == A_FLOAT && (int)av->a_w.w_float && av[1].a_type == A_SYMBOL) { @@ -656,7 +656,7 @@ static void comment_list(t_comment *x, t_symbol *s, int ac, t_atom *av) } donelist:; #ifdef COMMENT_DEBUG - post("donelist"); + loudbug_post("donelist"); #endif } @@ -664,7 +664,7 @@ static void comment_free(t_comment *x) { if (x->x_active) { - bug("comment_free"); + loudbug_bug("comment_free"); pd_unbind((t_pd *)x, gensym("#key")); pd_unbind((t_pd *)x, gensym("#keyname")); } diff --git a/cyclone/hammer/counter.c b/cyclone/hammer/counter.c index 73cd841..0b29b3f 100644 --- a/cyclone/hammer/counter.c +++ b/cyclone/hammer/counter.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -12,6 +12,7 @@ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define COUNTER_UP 0 #define COUNTER_DOWN 1 @@ -100,7 +101,7 @@ static void counter_dobang(t_counter *x, int notjam) if (x->x_inc == 1) { /* min has changed, which should imply x->x_count == x->x_min */ - bug("counter_dobang (count < min)"); + loudbug_bug("counter_dobang (count < min)"); } else if (x->x_dir == COUNTER_UPDOWN) { @@ -316,16 +317,12 @@ static void *counter_new(t_floatarg f1, t_floatarg f2, t_floatarg f3) int i2 = (int)f2; int i3 = (int)f3; int i; - shared_usecompatibility(); - if (shared_getmaxcompatibility()) + static int warned = 0; + if (fittermax_get() && !warned) { - static int warned = 0; - if (!warned) - { - post("warning: counter is not fully compatible,\ + post("warning: counter is not fully compatible,\ please report differences"); - warned = 1; - } + warned = 1; } x->x_dir = COUNTER_UP; x->x_inc = 1; /* previous value required by counter_dir() */ @@ -401,4 +398,5 @@ void counter_setup(void) CLASS_PD | CLASS_NOINLET, 0); class_addbang(counter_proxy_class, counter_proxy_bang); class_addfloat(counter_proxy_class, counter_proxy_float); + fitter_setup(counter_class, 0, 0); } diff --git a/cyclone/hammer/cycle.c b/cyclone/hammer/cycle.c index 244a64d..73f3b80 100644 --- a/cyclone/hammer/cycle.c +++ b/cyclone/hammer/cycle.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -7,6 +7,7 @@ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" //#define CYCLE_USEEVENTNO @@ -119,8 +120,7 @@ static void *cycle_new(t_floatarg f1, t_floatarg f2) nouts = CYCLE_DEFOUTS; if (nouts > CYCLE_C74MAXOUTS) { - shared_usecompatibility(); - loud_incompatible_max(cycle_class, CYCLE_C74MAXOUTS, "outlets"); + fittermax_rangewarning(cycle_class, CYCLE_C74MAXOUTS, "outlets"); /* CHECKED: max clips with an error: ``perhaps you were trying to make an oscillator?'' */ } @@ -151,4 +151,5 @@ void cycle_setup(void) gensym("set"), A_FLOAT, 0); /* CHECKED: arg required */ class_addmethod(cycle_class, (t_method)cycle_thresh, gensym("thresh"), A_FLOAT, 0); + fitter_setup(cycle_class, 0, 0); } diff --git a/cyclone/hammer/funbuff.c b/cyclone/hammer/funbuff.c index ff4773b..cde29f3 100644 --- a/cyclone/hammer/funbuff.c +++ b/cyclone/hammer/funbuff.c @@ -349,7 +349,7 @@ static void funbuff_dointerp(t_funbuff *x, t_floatarg f, int vsz, t_float *vec) float frac = f - np1->n_key; if (frac < 0 || frac >= delta) { - bug("funbuff_dointerp"); + loudbug_bug("funbuff_dointerp"); return; } frac /= delta; @@ -361,7 +361,7 @@ static void funbuff_dointerp(t_funbuff *x, t_floatarg f, int vsz, t_float *vec) float vfrac = vpos - vndx; if (vndx < 0 || vndx >= vsz - 1) { - bug("funbuff_dointerp redundant test..."); + loudbug_bug("funbuff_dointerp redundant test..."); return; } vec += vndx; diff --git a/cyclone/hammer/gate.c b/cyclone/hammer/gate.c index 80210cb..6fa2ac5 100644 --- a/cyclone/hammer/gate.c +++ b/cyclone/hammer/gate.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define GATE_MINOUTS 1 #define GATE_C74MAXOUTS 100 @@ -100,10 +101,7 @@ static void *gate_new(t_floatarg f1, t_floatarg f2) if (nouts < GATE_MINOUTS) nouts = GATE_DEFOUTS; if (nouts > GATE_C74MAXOUTS) - { - shared_usecompatibility(); - loud_incompatible_max(gate_class, GATE_C74MAXOUTS, "outlets"); - } + fittermax_rangewarning(gate_class, GATE_C74MAXOUTS, "outlets"); nouts++; /* for convenience (the cost is one pointer) */ if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs)))) return (0); @@ -147,4 +145,5 @@ void gate_setup(void) class_addpointer(gate_proxy_class, gate_proxy_pointer); class_addlist(gate_proxy_class, gate_proxy_list); class_addanything(gate_proxy_class, gate_proxy_anything); + fitter_setup(gate_class, 0, 0); } diff --git a/cyclone/hammer/hammer.c b/cyclone/hammer/hammer.c index ea4642c..a728ec7 100644 --- a/cyclone/hammer/hammer.c +++ b/cyclone/hammer/hammer.c @@ -1,8 +1,7 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -#include <stdio.h> #include "m_pd.h" #include "unstable/fragile.h" #include "common/loud.h" @@ -15,6 +14,7 @@ typedef struct _hammer { t_object x_ob; t_symbol *x_dir; + t_symbol *x_canvasdir; t_hammerfile *x_filehandle; } t_hammer; @@ -29,7 +29,8 @@ static void hammer_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) static void hammer_doimport(t_hammer *x, t_symbol *fn, t_symbol *dir) { - if (!dir || dir == &s_) dir = x->x_dir; + if (!dir || dir == &s_) + dir = x->x_dir; if (fn && fn != &s_) import_max(fn->s_name, (dir && dir != &s_) ? dir->s_name : ""); else @@ -47,6 +48,17 @@ static void hammer_import(t_hammer *x, t_symbol *fn) hammer_doimport(x, fn, 0); } +static void hammer_cd(t_hammer *x, t_symbol *dir) +{ + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); +} + +static void hammer_pwd(t_hammer *x) +{ + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); +} + static void hammer_bang(t_hammer *x) { fragile_class_printnames("hammer classes are: ", @@ -58,11 +70,13 @@ static void hammer_free(t_hammer *x) hammerfile_free(x->x_filehandle); } -static void *hammer_new(t_symbol *s) +static void *hammer_new(void) { t_hammer *x = (t_hammer *)pd_new(hammer_class); x->x_filehandle = hammerfile_new((t_pd *)x, 0, hammer_readhook, 0, 0); - x->x_dir = (s && s != &s_ ? s : canvas_getdir(x->x_filehandle->f_canvas)); + x->x_canvasdir = canvas_getdir(x->x_filehandle->f_canvas); + x->x_dir = x->x_canvasdir; + outlet_new((t_object *)x, &s_symbol); return (x); } @@ -87,8 +101,12 @@ void hammer_setup(void) hammer_class = class_new(gensym("hammer"), (t_newmethod)hammer_new, (t_method)hammer_free, - sizeof(t_hammer), 0, A_DEFSYM, 0); + sizeof(t_hammer), 0, 0); class_addbang(hammer_class, hammer_bang); + class_addmethod(hammer_class, (t_method)hammer_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(hammer_class, (t_method)hammer_pwd, + gensym("pwd"), 0); class_addmethod(hammer_class, (t_method)hammer_import, gensym("import"), A_DEFSYM, 0); class_addmethod(hammer_class, (t_method)hammer_click, diff --git a/cyclone/hammer/maximum.c b/cyclone/hammer/maximum.c index b5f6069..5f49765 100644 --- a/cyclone/hammer/maximum.c +++ b/cyclone/hammer/maximum.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define MAXIMUM_C74MAXITEMS 256 @@ -30,7 +31,7 @@ static void maximum_float(t_maximum *x, t_float f) static void maximum_list(t_maximum *x, t_symbol *s, int ac, t_atom *av) { if (ac > MAXIMUM_C74MAXITEMS) - loud_incompatible_max(*(t_pd *)x, MAXIMUM_C74MAXITEMS, "items"); + fittermax_rangewarning(*(t_pd *)x, MAXIMUM_C74MAXITEMS, "items"); while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME (a warning?) */ if (ac) { @@ -75,7 +76,6 @@ static void *maximum_new(t_floatarg f) t_maximum *x = (t_maximum *)pd_new(maximum_class); x->x_last = 0; /* CHECKME */ x->x_test = f; - shared_usecompatibility(); floatinlet_new((t_object *)x, &x->x_test); outlet_new((t_object *)x, &s_float); return (x); @@ -89,4 +89,5 @@ void maximum_setup(void) class_addbang(maximum_class, maximum_bang); class_addfloat(maximum_class, maximum_float); class_addlist(maximum_class, maximum_list); + fitter_setup(maximum_class, 0, 0); } diff --git a/cyclone/hammer/minimum.c b/cyclone/hammer/minimum.c index 71875fc..a1124a5 100644 --- a/cyclone/hammer/minimum.c +++ b/cyclone/hammer/minimum.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define MINIMUM_C74MAXITEMS 256 @@ -30,7 +31,7 @@ static void minimum_float(t_minimum *x, t_float f) static void minimum_list(t_minimum *x, t_symbol *s, int ac, t_atom *av) { if (ac > MINIMUM_C74MAXITEMS) - loud_incompatible_max(*(t_pd *)x, MINIMUM_C74MAXITEMS, "items"); + fittermax_rangewarning(*(t_pd *)x, MINIMUM_C74MAXITEMS, "items"); while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME (a warning?) */ if (ac) { @@ -75,7 +76,6 @@ static void *minimum_new(t_floatarg f) t_minimum *x = (t_minimum *)pd_new(minimum_class); x->x_last = 0; /* CHECKME */ x->x_test = f; - shared_usecompatibility(); floatinlet_new((t_object *)x, &x->x_test); outlet_new((t_object *)x, &s_float); return (x); @@ -89,4 +89,5 @@ void minimum_setup(void) class_addbang(minimum_class, minimum_bang); class_addfloat(minimum_class, minimum_float); class_addlist(minimum_class, minimum_list); + fitter_setup(minimum_class, 0, 0); } diff --git a/cyclone/hammer/mtr.c b/cyclone/hammer/mtr.c index 8b1b220..cf9927f 100644 --- a/cyclone/hammer/mtr.c +++ b/cyclone/hammer/mtr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003 krzYszcz and others. +/* Copyright (c) 2003-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -10,6 +10,7 @@ #include "m_pd.h" #include "shared.h" #include "common/loud.h" +#include "common/fitter.h" #include "hammer/file.h" #ifdef KRZYSZCZ @@ -181,7 +182,7 @@ static void mtrack_setmode(t_mtrack *tp, int newmode) mtrack_donext(tp); break; default: - bug("mtrack_setmode"); + loudbug_bug("mtrack_setmode"); } } @@ -286,7 +287,7 @@ static t_atom *mtrack_getdelay(t_mtrack *tp) return (ap); ap++; } - bug("mtrack_getdelay"); + loudbug_bug("mtrack_getdelay"); } return (0); } @@ -338,14 +339,11 @@ static void mtrack_write(t_mtrack *tp, t_symbol *s) static void mtrack_tempo(t_mtrack *tp, t_floatarg f) { float newtempo; - if (shared_getmaxcompatibility()) + static int warned = 0; + if (fittermax_get() && !warned) { - static int warned = 0; - if (!warned) - { - loud_incompatible(mtr_class, "no 'tempo' control in Max"); - warned = 1; - } + fittermax_warning(mtr_class, "no 'tempo' control in Max"); + warned = 1; } if (f < 1e-20) f = 1e-20; @@ -703,8 +701,8 @@ static void mtr_debug(t_mtr *x) t_mtrack **tpp = x->x_tracks; while (ntracks--) { - post("------- Track %d -------", (*tpp)->tr_id); - binbuf_print((*tpp++)->tr_binbuf); + loudbug_post("------- Track %d -------", (*tpp)->tr_id); + loudbug_postbinbuf((*tpp++)->tr_binbuf); } } #endif @@ -762,9 +760,8 @@ static void *mtr_new(t_floatarg f) x->x_glist = canvas_getcurrent(); x->x_filehandle = hammerfile_new((t_pd *)x, 0, mtr_readhook, mtr_writehook, 0); - shared_usecompatibility(); if (ntracks > MTR_C74MAXTRACKS) - loud_incompatible_max(mtr_class, MTR_C74MAXTRACKS, "tracks"); + fittermax_rangewarning(mtr_class, MTR_C74MAXTRACKS, "tracks"); x->x_ntracks = ntracks; x->x_tracks = tracks; for (id = 1; id <= ntracks; id++, tracks++) /* CHECKED 1-based */ @@ -863,4 +860,5 @@ void mtr_setup(void) gensym("debug"), 0); #endif hammerfile_setup(mtr_class, 0); + fitter_setup(mtr_class, 0, 0); } diff --git a/cyclone/hammer/past.c b/cyclone/hammer/past.c index bf4300c..553ccfa 100644 --- a/cyclone/hammer/past.c +++ b/cyclone/hammer/past.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -12,6 +12,7 @@ #include "m_pd.h" #include "common/loud.h" #include "common/grow.h" +#include "common/fitter.h" #define PAST_C74MAXSIZE 8 /* CHECKED */ @@ -112,8 +113,7 @@ static void past_set(t_past *x, t_symbol *s, int ac, t_atom *av) t_atom *vp = x->x_thresh; if (ac > x->x_size) { - shared_usecompatibility(); - loud_incompatible_max(past_class, PAST_C74MAXSIZE, "guard points"); + fittermax_rangewarning(past_class, PAST_C74MAXSIZE, "guard points"); x->x_thresh = grow_nodata(&ac, &x->x_size, x->x_thresh, PAST_C74MAXSIZE, x->x_thrini, sizeof(*x->x_thresh)); @@ -152,4 +152,5 @@ void past_setup(void) class_addlist(past_class, past_list); class_addmethod(past_class, (t_method)past_clear, gensym("clear"), 0); class_addmethod(past_class, (t_method)past_set, gensym("set"), A_GIMME, 0); + fitter_setup(past_class, 0, 0); } diff --git a/cyclone/hammer/prepend.c b/cyclone/hammer/prepend.c index 1b3bd73..2dbe7be 100644 --- a/cyclone/hammer/prepend.c +++ b/cyclone/hammer/prepend.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -6,6 +6,7 @@ #include "m_pd.h" #include "common/loud.h" #include "common/grow.h" +#include "common/fitter.h" #define PREPEND_INISIZE 32 /* LATER rethink */ #define PREPEND_MAXSIZE 256 @@ -33,6 +34,9 @@ typedef struct _prependxy static t_class *prepend_class; static t_class *prependxy_class; +static t_symbol *prependps_compatibility = 0; +static t_symbol *prependps_max; + /* Usually a preallocation method is used, except in special cases of: 1) reentrant output request, or 2) an output request which would cause resizing to more than MAXSIZE (no such limit for a 'set' message). @@ -149,9 +153,13 @@ static void prepend_bang(t_prepend *x) { if (x->x_selector) { - t_atom at; - SETSYMBOL(&at, &s_bang); /* CHECKED */ - prepend_doanything(x, 0, 1, &at); + if (prependps_compatibility == prependps_max) + { + t_atom at; + SETSYMBOL(&at, &s_bang); /* CHECKED */ + prepend_doanything(x, 0, 1, &at); + } + else prepend_doanything(x, 0, 0, 0); } else outlet_bang(((t_object *)x)->ob_outlet); } @@ -252,10 +260,11 @@ static void prepend_doset(t_prepend *x, t_symbol *s, int ac, t_atom *av) static void prepend_set(t_prepend *x, t_symbol *s, int ac, t_atom *av) { - if (shared_getmaxcompatibility()) - prepend_doset(x, 0, ac, av); - else + if (x->x_proxy) prepend_anything(x, s, ac, av); + else + /* LATER (when?) controlled by maxmode */ + prepend_doset(x, 0, ac, av); } static void prependxy_bang(t_prependxy *xy) @@ -292,7 +301,7 @@ static void prepend_free(t_prepend *x) freebytes(x->x_message, x->x_size * sizeof(*x->x_message)); if (x->x_auxbuf) { - bug("prepend_free"); /* LATER rethink */ + loudbug_bug("prepend_free"); /* LATER rethink */ freebytes(x->x_auxbuf, x->x_auxsize * sizeof(*x->x_auxbuf)); } if (x->x_proxy) @@ -308,7 +317,6 @@ static void *prepend_new(t_symbol *s, int ac, t_atom *av) x->x_message = x->x_messini; x->x_auxbuf = 0; x->x_entered = 0; - shared_usecompatibility(); if (ac) { x->x_proxy = 0; @@ -316,11 +324,10 @@ static void *prepend_new(t_symbol *s, int ac, t_atom *av) } else { - if (shared_getmaxcompatibility()) - /* CHECKED: this is still not compatible -- in max an object - without an outlet is created, and there is no warning when - loading from a file. */ - loud_incompatible(prepend_class, + if (prependps_compatibility == prependps_max) + /* CHECKED in max an object without an outlet is created, + and there is no warning when loading from a file. */ + fittermax_warning(prepend_class, "creating an object without an argument"); x->x_proxy = pd_new(prependxy_class); ((t_prependxy *)x->x_proxy)->xy_owner = x; @@ -352,4 +359,7 @@ void prepend_setup(void) class_addsymbol(prependxy_class, prependxy_symbol); class_addlist(prependxy_class, prependxy_list); class_addanything(prependxy_class, prependxy_anything); + + prependps_max = gensym("max"); + fitter_setup(prepend_class, &prependps_compatibility, 0); } diff --git a/cyclone/hammer/prob.c b/cyclone/hammer/prob.c index 6053808..8772d83 100644 --- a/cyclone/hammer/prob.c +++ b/cyclone/hammer/prob.c @@ -1,10 +1,11 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include <stdio.h> #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #include "common/rand.h" #include "hammer/file.h" @@ -144,9 +145,9 @@ static void prob_bang(t_prob *x) nextstate->tr_value); x->x_state = nextstate; } - else bug("prob_bang: void suffix"); + else loudbug_bug("prob_bang: void suffix"); } - else bug("prob_bang: search overflow"); + else loudbug_bug("prob_bang: search overflow"); } else { @@ -238,7 +239,7 @@ static void prob__silent(t_prob *x) { if (!x->x_silent) { - loud_incompatible(prob_class, "no '_silent' message in max"); + fittermax_warning(prob_class, "no '_silent' message in max"); x->x_silent = 1; } } @@ -276,7 +277,6 @@ static void *prob_new(void) x->x_embedmode = 0; /* CHECKED */ x->x_silent = 0; rand_seed(&x->x_seed, 0); - shared_usecompatibility(); outlet_new((t_object *)x, &s_float); x->x_bangout = outlet_new((t_object *)x, &s_bang); x->x_filehandle = hammerfile_new((t_pd *)x, prob_embedhook, 0, 0, 0); @@ -307,4 +307,5 @@ void prob_setup(void) gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); hammerfile_setup(prob_class, 1); + fitter_setup(prob_class, 0, 0); } diff --git a/cyclone/hammer/pv.c b/cyclone/hammer/pv.c index 235da2c..a444b51 100644 --- a/cyclone/hammer/pv.c +++ b/cyclone/hammer/pv.c @@ -75,7 +75,7 @@ static t_pvlist *pv_getlist(t_symbol *s, int create) pl->l_pvlist = 0; pd_bind(&pl->l_pd, s); } - else bug("pv_getlist"); + else loudbug_bug("pv_getlist"); } return (pl); } @@ -193,9 +193,9 @@ static t_pvfamily *pv_getfamily(t_glist *glist, t_symbol *s, if (pf->f_glist == gl) { if (mypf) - bug("pv_getfamily 1: %s in %s", - mypf->f_name->s_name, - mypf->f_glist->gl_name->s_name); + loudbug_bug("pv_getfamily 1: %s in %s", + mypf->f_name->s_name, + mypf->f_glist->gl_name->s_name); else return (0); } @@ -220,12 +220,12 @@ static t_pvfamily *pv_getfamily(t_glist *glist, t_symbol *s, break; } } - if (!pf) bug("pv_getfamily 2"); + if (!pf) loudbug_bug("pv_getfamily 2"); } pvfamily_free(mypf); } } - else bug("pv_getfamily 3"); + else loudbug_bug("pv_getfamily 3"); pvlist_decrement(pl); } else @@ -244,10 +244,10 @@ static t_pvfamily *pv_getfamily(t_glist *glist, t_symbol *s, pv_update(glist, pf); return (pf); } - else bug("pv_getfamily 4"); + else loudbug_bug("pv_getfamily 4"); } } - else bug("pv_getfamily 5"); + else loudbug_bug("pv_getfamily 5"); return (0); } @@ -255,7 +255,7 @@ static t_pvfamily *pv_checkfamily(t_pv *x) { if (!x->x_family) { - bug("pv_checkfamily"); + loudbug_bug("pv_checkfamily"); x->x_family = pv_getfamily(x->x_glist, x->x_name, 0, 0); } return (x->x_family); diff --git a/cyclone/hammer/seq.c b/cyclone/hammer/seq.c index c239478..97fd733 100644 --- a/cyclone/hammer/seq.c +++ b/cyclone/hammer/seq.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2004 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -11,6 +11,7 @@ #include "shared.h" #include "common/loud.h" #include "common/grow.h" +#include "common/fitter.h" #include "common/mifi.h" #include "unstable/forky.h" #include "hammer/file.h" @@ -101,7 +102,7 @@ static int seq_dogrowing(t_seq *x, int nevents, int ntempi) { int nrequested = nevents; #ifdef SEQ_DEBUG - post("growing for %d events...", nevents); + loudbug_post("growing for %d events...", nevents); #endif x->x_sequence = grow_nodata(&nrequested, &x->x_seqsize, x->x_sequence, @@ -117,7 +118,7 @@ static int seq_dogrowing(t_seq *x, int nevents, int ntempi) { int nrequested = ntempi; #ifdef SEQ_DEBUG - post("growing for %d tempi...", ntempi); + loudbug_post("growing for %d tempi...", ntempi); #endif x->x_tempomap = grow_nodata(&nrequested, &x->x_tempomapsize, x->x_tempomap, @@ -157,7 +158,7 @@ static void seq_complete(t_seq *x) /* store-ahead scheme, LATER consider using x_currevent */ int nrequested = x->x_nevents + 1; #ifdef SEQ_DEBUG - post("growing..."); + loudbug_post("growing..."); #endif x->x_sequence = grow_withdata(&nrequested, &nexisting, @@ -212,7 +213,7 @@ static void seq_addbyte(t_seq *x, unsigned char c, int docomplete) else if (x->x_evelength == 4) { if (x->x_status != 240) - bug("seq_addbyte"); + loudbug_bug("seq_addbyte"); /* CHECKED sysex is broken into 4-byte packets marked with the actual delta time of last byte received in a packet */ seq_complete(x); @@ -323,7 +324,7 @@ static void seq_setmode(t_seq *x, int newmode) seq_stopslavery(x); break; default: - bug("seq_setmode (old)"); + loudbug_bug("seq_setmode (old)"); return; } x->x_mode = newmode; @@ -342,7 +343,7 @@ static void seq_setmode(t_seq *x, int newmode) seq_startslavery(x, changed); break; default: - bug("seq_setmode (new)"); + loudbug_bug("seq_setmode (new)"); } } @@ -422,13 +423,13 @@ static void seq_tick(t_seq *x) return; clock_delay(x->x_slaveclock, elapsed); seq_settimescale(x, (float)(elapsed * (SEQ_TICKSPERSEC / 1000.))); - if (x->x_prevtime > 0) + if (x->x_prevtime > 0.) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; } else x->x_clockdelay = - x->x_sequence[x->x_playhead].e_delta * x->x_newtimescale; + x->x_sequence[x->x_playhead].e_delta * x->x_newtimescale; if (x->x_clockdelay < 0.) x->x_clockdelay = 0.; clock_delay(x->x_clock, x->x_clockdelay); @@ -547,6 +548,73 @@ static void seq_hook(t_seq *x, t_floatarg f) } } +static void seq_pause(t_seq *x) +{ + static int warned = 0; + if (fittermax_get() && !warned) + { + fittermax_warning(*(t_pd *)x, "'pause' not supported in Max"); + warned = 1; + } + if (x->x_mode == SEQ_PLAYMODE && x->x_prevtime > 0.) + { + x->x_clockdelay -= clock_gettimesince(x->x_prevtime); + if (x->x_clockdelay < 0.) + x->x_clockdelay = 0.; + clock_unset(x->x_clock); + x->x_prevtime = 0.; + } +} + +static void seq_continue(t_seq *x) +{ + static int warned = 0; + if (fittermax_get() && !warned) + { + fittermax_warning(*(t_pd *)x, "'continue' not supported in Max"); + warned = 1; + } + if (x->x_mode == SEQ_PLAYMODE) + { + if (x->x_clockdelay < 0.) + x->x_clockdelay = 0.; + clock_delay(x->x_clock, x->x_clockdelay); + x->x_prevtime = clock_getlogicaltime(); + } +} + +static void seq_goto(t_seq *x, t_floatarg f1, t_floatarg f2) +{ + static int warned = 0; + if (fittermax_get() && !warned) + { + fittermax_warning(*(t_pd *)x, "'goto' not supported in Max"); + warned = 1; + } + if (x->x_nevents && x->x_mode == SEQ_PLAYMODE) + { + t_seqevent *ev; + int ndx, nevents = x->x_nevents; + double ms = f1 * 1000. + f2, sum; + if (ms < SEQ_TICKEPSILON) + ms = 0.; + for (ndx = 0, ev = x->x_sequence, sum = SEQ_TICKEPSILON; ndx < nevents; + ndx++, ev++) + { + if ((sum += ev->e_delta) >= ms) + { + x->x_playhead = ndx; + x->x_clockdelay = sum - SEQ_TICKEPSILON - ms; + if (x->x_clockdelay < 0.) + x->x_clockdelay = 0.; + clock_delay(x->x_clock, x->x_clockdelay); + x->x_prevtime = clock_getlogicaltime(); + break; + } + } + } +} + static int seq_eventcomparehook(const void *e1, const void *e2) { return (((t_seqevent *)e1)->e_delta > ((t_seqevent *)e2)->e_delta ? 1 : -1); @@ -584,7 +652,7 @@ static int seq_mrhook(t_mifiread *mr, void *hookdata, int evtype) } else if (x->x_eventreadhead == x->x_nevents) { - bug("seq_mrhook 1"); + loudbug_bug("seq_mrhook 1"); x->x_eventreadhead++; } } @@ -596,12 +664,12 @@ static int seq_mrhook(t_mifiread *mr, void *hookdata, int evtype) stm->t_scoretime = scoretime; stm->t_sr = mifiread_gettempo(mr); #ifdef SEQ_DEBUG - post("tempo %g at %g", stm->t_sr, scoretime); + loudbug_post("tempo %g at %g", stm->t_sr, scoretime); #endif } else if (x->x_temporeadhead == x->x_ntempi) { - bug("seq_mrhook 2"); + loudbug_bug("seq_mrhook 2"); x->x_temporeadhead++; } } @@ -641,13 +709,13 @@ static int seq_mfread(t_seq *x, char *path) if (!mifiread_open(mr, path, "", 0)) goto mfreadfailed; #ifdef SEQ_DEBUG - startpost("midifile (format %d): %d tracks, %d ticks", - mifiread_getformat(mr), mifiread_gethdtracks(mr), - mifiread_getbeatticks(mr)); + loudbug_startpost("midifile (format %d): %d tracks, %d ticks", + mifiread_getformat(mr), mifiread_gethdtracks(mr), + mifiread_getbeatticks(mr)); if (mifiread_getnframes(mr)) - post(" (%d smpte frames)", mifiread_getnframes(mr)); + loudbug_post(" (%d smpte frames)", mifiread_getnframes(mr)); else - post(" per beat"); + loudbug_post(" per beat"); #endif if (!seq_dogrowing(x, mifiread_getnevents(mr), mifiread_getntempi(mr))) goto mfreadfailed; @@ -657,8 +725,9 @@ static int seq_mfread(t_seq *x, char *path) goto mfreadfailed; if (x->x_eventreadhead < x->x_nevents) { - bug("seq_mfread 1"); - post("declared %d events, got %d", x->x_nevents, x->x_eventreadhead); + loudbug_bug("seq_mfread 1"); + loudbug_post("declared %d events, got %d", + x->x_nevents, x->x_eventreadhead); x->x_nevents = x->x_eventreadhead; } if (x->x_nevents) @@ -666,8 +735,9 @@ static int seq_mfread(t_seq *x, char *path) seq_eventcomparehook); if (x->x_temporeadhead < x->x_ntempi) { - bug("seq_mfread 2"); - post("declared %d tempi, got %d", x->x_ntempi, x->x_temporeadhead); + loudbug_bug("seq_mfread 2"); + loudbug_post("declared %d tempi, got %d", + x->x_ntempi, x->x_temporeadhead); x->x_ntempi = x->x_temporeadhead; } if (x->x_ntempi) @@ -675,7 +745,7 @@ static int seq_mfread(t_seq *x, char *path) seq_tempocomparehook); seq_foldtime(x, mifiread_getdeftempo(mr)); #ifdef SEQ_DEBUG - post("seq: got %d events from midi file", x->x_nevents); + loudbug_post("seq: got %d events from midi file", x->x_nevents); #endif result = 1; mfreadfailed: @@ -982,7 +1052,7 @@ static void *seq_new(t_symbol *s) { t_seq *x = (t_seq *)pd_new(seq_class); static int warned = 0; - if (!warned) + if (fittermax_get() && !warned) { loud_warning((t_pd *)x, 0, "seq is not ready yet"); warned = 1; @@ -1046,6 +1116,15 @@ void seq_setup(void) gensym("write"), A_DEFSYM, 0); class_addmethod(seq_class, (t_method)seq_print, gensym("print"), 0); + + class_addmethod(seq_class, (t_method)seq_pause, + gensym("pause"), 0); + class_addmethod(seq_class, (t_method)seq_continue, + gensym("continue"), 0); + class_addmethod(seq_class, (t_method)seq_goto, + gensym("goto"), A_DEFFLOAT, A_DEFFLOAT, 0); + forky_setpropertiesfn(seq_class, seq_properties); hammerfile_setup(seq_class, 0); + fitter_setup(seq_class, 0, 0); } diff --git a/cyclone/hammer/sprintf.c b/cyclone/hammer/sprintf.c index 47d94ec..8c9aefd 100644 --- a/cyclone/hammer/sprintf.c +++ b/cyclone/hammer/sprintf.c @@ -121,18 +121,18 @@ static void sprintf_proxy_checkit(t_sprintf_proxy *x, char *buf, int checkin) } *pattend = tmp; } - else bug("sprintf_proxy_checkit"); + else loudbug_bug("sprintf_proxy_checkit"); if (x->p_valid = valid) { #ifdef SPRINTF_DEBUG - if (checkin) post("[%d in \"%s\"]", result, buf); + if (checkin) loudbug_post("[%d in \"%s\"]", result, buf); #endif x->p_size = result; } else { #ifdef SPRINTF_DEBUG - if (checkin) post("checkit failed"); + if (checkin) loudbug_post("checkit failed"); #endif x->p_size = 0; } @@ -553,7 +553,7 @@ static void *sprintf_new(t_symbol *s, int ac, t_atom *av) return (x); } #ifdef SPRINTF_DEBUG - post("%d slots:", nproxies); + loudbug_post("%d slots:", nproxies); #endif /* CHECKED: max creates as many inlets, as there are %-signs, no matter if they are valid, or not -- if not, it prints ``can't convert'' errors @@ -589,8 +589,8 @@ static void *sprintf_new(t_symbol *s, int ac, t_atom *av) #ifdef SPRINTF_DEBUG char tmp = *p1; *p1 = 0; - poststring(p2); - endpost(); + loudbug_poststring(p2); + loudbug_endpost(); *p1 = tmp; #endif if (i < nslots) @@ -615,7 +615,7 @@ static void *sprintf_new(t_symbol *s, int ac, t_atom *av) } } #ifdef SPRINTF_DEBUG - post("printf(\"%s\", ...)", fstring); + loudbug_post("printf(\"%s\", ...)", fstring); #endif outlet_new((t_object *)x, &s_anything); return (x); diff --git a/cyclone/hammer/switch.c b/cyclone/hammer/switch.c index 03c9f7f..ce985de 100644 --- a/cyclone/hammer/switch.c +++ b/cyclone/hammer/switch.c @@ -1,9 +1,10 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #define SWITCH_MININLETS 2 /* LATER consider using 1 (with a warning) */ #define SWITCH_C74MAXINLETS 100 @@ -103,10 +104,7 @@ static void *switch_new(t_floatarg f1, t_floatarg f2) if (nproxies < SWITCH_MININLETS) nproxies = SWITCH_DEFINLETS; if (nproxies > SWITCH_C74MAXINLETS) - { - shared_usecompatibility(); - loud_incompatible_max(switch_class, SWITCH_C74MAXINLETS, "inlets"); - } + fittermax_rangewarning(switch_class, SWITCH_C74MAXINLETS, "inlets"); if (!(proxies = (t_pd **)getbytes(nproxies * sizeof(*proxies)))) return (0); for (ninlets = 0; ninlets < nproxies; ninlets++) @@ -152,4 +150,5 @@ void switch_setup(void) class_addpointer(switch_proxy_class, switch_proxy_pointer); class_addlist(switch_proxy_class, switch_proxy_list); class_addanything(switch_proxy_class, switch_proxy_anything); + fitter_setup(switch_class, 0, 0); } diff --git a/cyclone/hammer/tosymbol.c b/cyclone/hammer/tosymbol.c index 8b45ad0..3b5feff 100644 --- a/cyclone/hammer/tosymbol.c +++ b/cyclone/hammer/tosymbol.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <string.h> #include "m_pd.h" +#include "common/loud.h" #include "common/grow.h" #define TOSYMBOL_INISTRING 128 /* LATER rethink */ @@ -99,7 +100,7 @@ static int tosymbol_parse(t_symbol *s, int ac, t_atom *av, t_symbol *separator, } if (nleft < 0) { - bug("tosymbol_parse"); + loudbug_bug("tosymbol_parse"); return (bufsize); } return (bufsize - nleft); @@ -111,7 +112,7 @@ static void tosymbol_anything(t_tosymbol *x, t_symbol *s, int ac, t_atom *av) { if (tosymbol_bufferlocked) { - bug("tosymbol_anything"); + loudbug_bug("tosymbol_anything"); tosymbol_parse(s, ac, av, x->x_separator, x->x_bufsize, x->x_buffer); } diff --git a/cyclone/hammer/urn.c b/cyclone/hammer/urn.c index f496616..b02d891 100644 --- a/cyclone/hammer/urn.c +++ b/cyclone/hammer/urn.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* Copyright (c) 2002-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -9,8 +9,9 @@ #include "m_pd.h" #include "common/loud.h" -#include "common/rand.h" #include "common/grow.h" +#include "common/fitter.h" +#include "common/rand.h" #define URN_INISIZE 128 /* LATER rethink */ #define URN_C74MAXSIZE 4096 /* CHECKED */ @@ -56,7 +57,7 @@ static int urn_resize(t_urn *x, t_float f, int init) range = URN_MAXSIZE; } if (range > maxmax) - loud_incompatible_max(urn_class, maxmax, "elements"); + fittermax_rangewarning(urn_class, maxmax, "elements"); x->x_range = range; if (range > x->x_size) x->x_urn = grow_nodata(&x->x_range, &x->x_size, x->x_urn, @@ -122,7 +123,6 @@ static void *urn_new(t_floatarg f1, t_floatarg f2) x->x_urn = x->x_urnini; urn_resize(x, f1, 1); urn_seed(x, f2); /* CHECKME */ - shared_usecompatibility(); inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); outlet_new((t_object *)x, &s_float); x->x_bangout = outlet_new((t_object *)x, &s_bang); @@ -146,4 +146,5 @@ void urn_setup(void) gensym("seed"), A_FLOAT, 0); /* CHECKED arg obligatory */ class_addmethod(urn_class, (t_method)urn_clear, gensym("clear"), 0); + fitter_setup(urn_class, 0, 0); } diff --git a/cyclone/hammer/zl.c b/cyclone/hammer/zl.c index 7a5d471..b263bc8 100644 --- a/cyclone/hammer/zl.c +++ b/cyclone/hammer/zl.c @@ -13,7 +13,7 @@ /* LATER test reentrancy, tune speedwise */ #ifdef KRZYSZCZ -#define ZL_DEBUG +//#define ZL_DEBUG #endif #define ZL_INISIZE 32 /* LATER rethink */ @@ -820,6 +820,8 @@ static void zl_mode(t_zl *x, t_symbol *s, int ac, t_atom *av) if (i && i < zl_nmodes) { x->x_mode = i; + /* CHECKED incompatible (LATER warn): + c74 rejects creation args, if not a single int */ zl_setmodearg(x, 0, ac - 1, av + 1); } } @@ -882,19 +884,19 @@ static void zlproxy_anything(t_zlproxy *p, t_symbol *s, int ac, t_atom *av) #ifdef ZL_DEBUG static void zl_debug(t_zl *x, t_floatarg f) { - startpost("mode %s", zl_modesym[x->x_mode]->s_name); + loudbug_startpost("mode %s", zl_modesym[x->x_mode]->s_name); if (zl_intargfn[x->x_mode]) - post(" %d", x->x_modearg); + loudbug_post(" %d", x->x_modearg); else - endpost(); + loudbug_endpost(); if ((int)f) { - startpost("first:"); - postatom(x->x_inbuf1.d_natoms, x->x_inbuf1.d_buf); - endpost(); - startpost("second:"); - postatom(x->x_inbuf2.d_natoms, x->x_inbuf2.d_buf); - endpost(); + loudbug_startpost("first:"); + loudbug_postatom(x->x_inbuf1.d_natoms, x->x_inbuf1.d_buf); + loudbug_endpost(); + loudbug_startpost("second:"); + loudbug_postatom(x->x_inbuf2.d_natoms, x->x_inbuf2.d_buf); + loudbug_endpost(); } } #endif @@ -940,7 +942,7 @@ static void zl_setupmode(char *id, int flags, zl_doitfn[zl_nmodes] = dfn; zl_nmodes++; } - else bug("zl_setupmode"); + else loudbug_bug("zl_setupmode"); } static void zl_setupallmodes(void) |