From 6435314717c5fb8fa062eb682c72c8df095b1be3 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 11 Jan 2005 10:33:23 +0000 Subject: svf~: args parsing; prepend/Append: bang handling; seq: pause, continue, goto; many maxmode changes svn path=/trunk/externals/miXed/; revision=2490 --- Makefile.common | 21 ++++- Makefile.dirs | 6 +- ViCious/cyclone/objects | 11 +++ cyclone/Makefile.objects | 18 ++-- cyclone/Makefile.sources | 40 +++++---- cyclone/build_counter | 4 +- cyclone/cyclone-shared.include | 10 ++- cyclone/hammer/Append.c | 63 ++++++++++--- cyclone/hammer/Decode.c | 7 +- cyclone/hammer/Makefile.objects | 1 + cyclone/hammer/Table.c | 4 +- cyclone/hammer/bangbang.c | 9 +- cyclone/hammer/coll.c | 54 +++++------ cyclone/hammer/comment.c | 34 +++---- cyclone/hammer/counter.c | 18 ++-- cyclone/hammer/cycle.c | 7 +- cyclone/hammer/funbuff.c | 4 +- cyclone/hammer/gate.c | 9 +- cyclone/hammer/hammer.c | 30 +++++-- cyclone/hammer/maximum.c | 7 +- cyclone/hammer/minimum.c | 7 +- cyclone/hammer/mtr.c | 26 +++--- cyclone/hammer/past.c | 7 +- cyclone/hammer/prepend.c | 38 +++++--- cyclone/hammer/prob.c | 11 +-- cyclone/hammer/pv.c | 18 ++-- cyclone/hammer/seq.c | 125 +++++++++++++++++++++----- cyclone/hammer/sprintf.c | 14 +-- cyclone/hammer/switch.c | 9 +- cyclone/hammer/tosymbol.c | 5 +- cyclone/hammer/urn.c | 9 +- cyclone/hammer/zl.c | 24 ++--- cyclone/shadow/Makefile.objects | 1 + cyclone/shadow/cyclone.c | 140 ++++++++++++----------------- cyclone/shadow/dummies.c | 20 ++--- cyclone/shadow/maxmode.c | 175 ++++++++++++++++++++++++++++++++++-- cyclone/sickle/Line.c | 14 +-- cyclone/sickle/Makefile.objects | 1 + cyclone/sickle/Scope.c | 22 +++-- cyclone/sickle/average.c | 3 +- cyclone/sickle/bitshift.c | 9 +- cyclone/sickle/buffir.c | 16 ++-- cyclone/sickle/curve.c | 16 ++-- cyclone/sickle/cycle.c | 2 +- cyclone/sickle/pong.c | 3 +- cyclone/sickle/sickle.c | 30 +++++-- cyclone/sickle/svf.c | 45 +++++++--- shared/Makefile.dirs | 2 +- shared/common/Makefile.sources | 1 + shared/common/clc.c | 1 + shared/common/dict.c | 2 +- shared/common/fitter.c | 195 ++++++++++++++++++++++++++++++++++++++++ shared/common/fitter.h | 20 +++++ shared/common/grow.c | 2 +- shared/common/lex.c | 2 +- shared/common/loud.c | 184 ++++++++++++++++--------------------- shared/common/loud.h | 16 ++-- shared/common/mifi.c | 111 ++++++++++++++--------- shared/common/mifi.h | 51 +++++++---- shared/common/port.c | 43 ++++----- shared/common/props.c | 2 +- shared/common/qtree.c | 89 +++++++++--------- shared/common/rand.c | 2 +- shared/common/vefl.c | 4 +- shared/getridof.baddeps | 1 + shared/sickle/arsic.c | 7 +- shared/sickle/sic.c | 9 +- shared/toxy/plusbob.c | 22 ++--- shared/toxy/scriptlet.c | 13 ++- test/cyclone/cyclone-test.pd | 66 +++++++------- test/cyclone/maxmode-test.pd | 46 ++++++---- toxy/plustot.c | 103 +++++++++++---------- toxy/plustot.qlist.c | 5 +- toxy/tot.c | 21 ++--- toxy/widget.c | 188 ++++++++++++++++---------------------- toxy/widgettype.c | 16 ++-- 76 files changed, 1481 insertions(+), 890 deletions(-) create mode 100644 shared/common/fitter.c create mode 100644 shared/common/fitter.h diff --git a/Makefile.common b/Makefile.common index 93ffeb3..aec8e9e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -10,7 +10,15 @@ endif OS_NAME = $(shell uname -s) ifneq ($(OS_NAME),Linux) ifneq ($(OS_NAME),Darwin) -# FIXME +ifeq (,$(findstring MinGW,$(OS_NAME))) +ifeq (,$(findstring MINGW,$(OS_NAME))) +$(error Fatal error: unknown environment "$(OS_NAME)". Aborting...) +else +OS_NAME = MinGW +endif +else +OS_NAME = MinGW +endif endif endif @@ -35,12 +43,13 @@ DEFINES = -DUNIX endif endif +# FIXME test if it actually works ifeq ($(OS_NAME),MinGW) CC = gcc X_SUFFIX = dll DEFINES = -DNT -DMSW OPT_CFLAGS = -funroll-loops -LFLAGS = -shared $(PD_DIR)/../bin/pd.dll +LFLAGS = -shared $(PD_DIR)/../bin/pd.dll -Wl,--enable-runtime-pseudo-reloc endif ifeq ($(OS_NAME),Darwin) @@ -140,6 +149,14 @@ $(if $(word 21,$(TYPES)),$(call TYPES_RULE,$(word 21,$(TYPES)))) $(if $(word 22,$(TYPES)),$(call TYPES_RULE,$(word 22,$(TYPES)))) $(if $(word 23,$(TYPES)),$(call TYPES_RULE,$(word 23,$(TYPES)))) $(if $(word 24,$(TYPES)),$(call TYPES_RULE,$(word 24,$(TYPES)))) +$(if $(word 25,$(TYPES)),$(call TYPES_RULE,$(word 25,$(TYPES)))) +$(if $(word 26,$(TYPES)),$(call TYPES_RULE,$(word 26,$(TYPES)))) +$(if $(word 27,$(TYPES)),$(call TYPES_RULE,$(word 27,$(TYPES)))) +$(if $(word 28,$(TYPES)),$(call TYPES_RULE,$(word 28,$(TYPES)))) +$(if $(word 29,$(TYPES)),$(call TYPES_RULE,$(word 29,$(TYPES)))) +$(if $(word 30,$(TYPES)),$(call TYPES_RULE,$(word 30,$(TYPES)))) +$(if $(word 31,$(TYPES)),$(call TYPES_RULE,$(word 31,$(TYPES)))) +$(if $(word 32,$(TYPES)),$(call TYPES_RULE,$(word 32,$(TYPES)))) SHOBJECTS = $(foreach fn,$(SHARED_OBJECTS),$(SHARED_DIR)/$(fn)) LXSHOBJECTS = $(foreach fn,$(LXSHARED_OBJECTS),$(SHARED_DIR)/$(fn)) diff --git a/Makefile.dirs b/Makefile.dirs index 55e7d03..8f6e0d9 100644 --- a/Makefile.dirs +++ b/Makefile.dirs @@ -1,8 +1,10 @@ MIXED_DIRS = \ shared \ cyclone \ - toxy + toxy \ + xeq RELEASE_DIRS = \ cyclone \ - toxy + toxy \ + xeq diff --git a/ViCious/cyclone/objects b/ViCious/cyclone/objects index c74d47b..34a9deb 100644 --- a/ViCious/cyclone/objects +++ b/ViCious/cyclone/objects @@ -97,6 +97,7 @@ HAMMER_OBJECTS = $(ALL_HAMMERS) \ $(SRCDIR)\hammer\allhammers.obj \ $(SHAREDDIR)\common\loud.obj \ $(SHAREDDIR)\common\grow.obj \ + $(SHAREDDIR)\common\fitter.obj \ $(SHAREDDIR)\common\rand.obj \ $(SHAREDDIR)\common\vefl.obj \ $(SHAREDDIR)\common\mifi.obj \ @@ -193,6 +194,7 @@ SICKLE_OBJECTS = $(ALL_SICKLES) \ $(SRCDIR)\sickle\allsickles.obj \ $(SHAREDDIR)\common\loud.obj \ $(SHAREDDIR)\common\grow.obj \ + $(SHAREDDIR)\common\fitter.obj \ $(SHAREDDIR)\common\vefl.obj \ $(SHAREDDIR)\common\clc.obj \ $(SHAREDDIR)\common\lex.obj \ @@ -219,4 +221,13 @@ DUMMIES_OBJECTS = \ MAXMODE_OBJECTS = \ $(SRCDIR)\shadow\maxmode.obj \ $(SHAREDDIR)\common\loud.obj \ + $(SHAREDDIR)\common\grow.obj \ + $(SHAREDDIR)\common\fitter.obj \ + $(SHAREDDIR)\common\lex.obj \ + $(SHAREDDIR)\common\binport.obj \ + $(SHAREDDIR)\common\port.obj \ + $(SHAREDDIR)\hammer\file.obj \ + $(SHAREDDIR)\unstable\forky.obj \ + $(SHAREDDIR)\unstable\fragile.obj \ + $(SHAREDDIR)\unstable\fringe.obj \ $(SHAREDDIR)\unstable\loader.obj diff --git a/cyclone/Makefile.objects b/cyclone/Makefile.objects index 5199008..2a076ba 100644 --- a/cyclone/Makefile.objects +++ b/cyclone/Makefile.objects @@ -1,11 +1,14 @@ HLOUD_OBJECTS = common/loud.o +HFITTER_OBJECTS = common/loud.o common/fitter.o HFORKY_OBJECTS = common/loud.o unstable/forky.o HFRAGILE_OBJECTS = common/loud.o unstable/fragile.o HGROW_OBJECTS = common/grow.o common/loud.o -HFILE_OBJECTS = hammer/file.o common/loud.o unstable/forky.o +HGROWFITTER_OBJECTS = common/grow.o common/loud.o common/fitter.o +HFILE_OBJECTS = hammer/file.o common/loud.o common/fitter.o unstable/forky.o HRAND_OBJECTS = common/rand.o common/loud.o -HRANDFILE_OBJECTS = common/rand.o hammer/file.o common/loud.o unstable/forky.o -HRANDGROW_OBJECTS = common/rand.o common/grow.o common/loud.o +HRANDFILE_OBJECTS = common/rand.o hammer/file.o common/loud.o common/fitter.o \ + unstable/forky.o +HRANDGROW_OBJECTS = common/rand.o common/grow.o common/loud.o common/fitter.o HRANDGROWFILE_OBJECTS = common/rand.o common/grow.o hammer/file.o \ common/loud.o unstable/forky.o HTREE_OBJECTS = hammer/tree.o common/loud.o @@ -13,16 +16,19 @@ HTREEFILEVEFL_OBJECTS = hammer/tree.o hammer/file.o \ common/vefl.o common/loud.o unstable/forky.o unstable/fragile.o HGUI_OBJECTS = hammer/gui.o common/loud.o HSEQ_OBJECTS = common/mifi.o hammer/file.o \ - common/grow.o common/loud.o unstable/forky.o + common/grow.o common/loud.o common/fitter.o unstable/forky.o SSIC_OBJECTS = sickle/sic.o common/loud.o SFORKY_OBJECTS = sickle/sic.o common/loud.o unstable/forky.o SFRAGILE_OBJECTS = sickle/sic.o common/loud.o unstable/fragile.o SGROW_OBJECTS = common/grow.o sickle/sic.o common/loud.o SGROWCLC_OBJECTS = common/grow.o common/clc.o sickle/sic.o common/loud.o -SGROWFORKY_OBJECTS = common/grow.o sickle/sic.o common/loud.o unstable/forky.o +SGROWFORKY_OBJECTS = common/grow.o sickle/sic.o \ + common/loud.o common/fitter.o unstable/forky.o SVEFL_OBJECTS = common/vefl.o sickle/sic.o common/loud.o unstable/fragile.o SARSIC_OBJECTS = sickle/sic.o sickle/arsic.o common/vefl.o \ common/loud.o unstable/fragile.o +SARSICFITTER_OBJECTS = sickle/sic.o sickle/arsic.o common/vefl.o \ + common/loud.o common/fitter.o unstable/fragile.o SFILE_OBJECTS = hammer/file.o sickle/sic.o common/loud.o unstable/forky.o -RELEASE_LIBS = cyclone hammer sickle dummies +RELEASE_LIBS = cyclone hammer sickle dummies maxmode RELEASE_APPS = cyclist diff --git a/cyclone/Makefile.sources b/cyclone/Makefile.sources index 0c338fe..bcadba2 100644 --- a/cyclone/Makefile.sources +++ b/cyclone/Makefile.sources @@ -1,7 +1,8 @@ -TYPES = HPLAIN HLOUD HFORKY HFRAGILE HGROW HFILE HRAND HRANDFILE HRANDGROW \ - HRANDGROWFILE HTREE HTREEFILEVEFL HGUI HSEQ \ - SPLAINNOTILDE SPLAIN SSIC SFORKY SFRAGILE SGROW SGROWFORKY \ - SVEFL SARSIC SFILE +TYPES = HPLAIN HLOUD HFITTER HFORKY HFRAGILE HGROW HGROWFITTER \ + HFILE HRAND HRANDFILE HRANDGROW HRANDGROWFILE \ + HTREE HTREEFILEVEFL HGUI HSEQ \ + SPLAINNOTILDE SPLAIN SSIC SFORKY SFRAGILE SGROW SGROWCLC SGROWFORKY \ + SVEFL SARSIC SARSICFITTER SFILE HPLAIN_SOURCES = \ hammer/testmess.c \ @@ -37,22 +38,24 @@ hammer/xnoteout.c HLOUD_SOURCES = \ hammer/anal.c \ -hammer/bangbang.c \ hammer/Borax.c \ -hammer/counter.c \ -hammer/cycle.c \ hammer/decide.c \ -hammer/Decode.c \ -hammer/gate.c \ hammer/Histo.c \ -hammer/maximum.c \ -hammer/minimum.c \ hammer/spell.c \ hammer/spray.c \ hammer/sprintf.c \ -hammer/switch.c \ hammer/TogEdge.c +HFITTER_SOURCES = \ +hammer/bangbang.c \ +hammer/counter.c \ +hammer/cycle.c \ +hammer/Decode.c \ +hammer/gate.c \ +hammer/maximum.c \ +hammer/minimum.c \ +hammer/switch.c + HFORKY_SOURCES = \ hammer/comment.c @@ -61,15 +64,12 @@ hammer/grab.c \ hammer/universal.c HGROW_SOURCES = \ -hammer/Append.c \ hammer/bondo.c \ hammer/buddy.c \ hammer/Clip.c \ hammer/funnel.c \ hammer/iter.c \ hammer/match.c \ -hammer/past.c \ -hammer/prepend.c \ hammer/pv.c \ hammer/speedlim.c \ hammer/substitute.c \ @@ -77,6 +77,11 @@ hammer/thresh.c \ hammer/tosymbol.c \ hammer/zl.c +HGROWFITTER_SOURCES = \ +hammer/Append.c \ +hammer/past.c \ +hammer/prepend.c + HFILE_SOURCES = \ hammer/capture.c \ hammer/coll.c \ @@ -200,7 +205,6 @@ sickle/cycle.c SARSIC_TILDE = $(TILDE) SARSIC_SOURCES = \ -sickle/buffir.c \ sickle/index.c \ sickle/lookup.c \ sickle/peek.c \ @@ -209,6 +213,10 @@ sickle/poke.c \ sickle/record.c \ sickle/wave.c +SARSICFITTER_TILDE = $(TILDE) +SARSICFITTER_SOURCES = \ +sickle/buffir.c + SFILE_TILDE = $(TILDE) SFILE_SOURCES = \ sickle/capture.c diff --git a/cyclone/build_counter b/cyclone/build_counter index acc65a6..10003f3 100644 --- a/cyclone/build_counter +++ b/cyclone/build_counter @@ -1,7 +1,7 @@ #define CYCLONE_VERSION "0.1" #define CYCLONE_RELEASE "alpha" -#define CYCLONE_BUILD 50 +#define CYCLONE_BUILD 51 #if 0 -CYCLONE_SNAPSHOT = 0.1-alpha50 +CYCLONE_SNAPSHOT = 0.1-alpha51 #endif diff --git a/cyclone/cyclone-shared.include b/cyclone/cyclone-shared.include index 26662ac..6b0cce8 100644 --- a/cyclone/cyclone-shared.include +++ b/cyclone/cyclone-shared.include @@ -9,10 +9,16 @@ shared/unstable/fringe.h shared/unstable/loader.c shared/unstable/loader.h shared/unstable/pd_imp.h -shared/common/grow.c -shared/common/grow.h +shared/unstable/standalone.c +shared/unstable/standalone.h shared/common/loud.c shared/common/loud.h +shared/common/grow.c +shared/common/grow.h +shared/common/fitter.c +shared/common/fitter.h +shared/common/lex.c +shared/common/lex.h shared/common/binport.c shared/common/binport.h shared/common/port.c 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 #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 #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 #include #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) diff --git a/cyclone/shadow/Makefile.objects b/cyclone/shadow/Makefile.objects index dd8fb57..66aea0d 100644 --- a/cyclone/shadow/Makefile.objects +++ b/cyclone/shadow/Makefile.objects @@ -1,6 +1,7 @@ SHARED_OBJECTS = \ common/loud.o \ common/grow.o \ +common/fitter.o \ common/lex.o \ common/binport.o \ common/port.o \ diff --git a/cyclone/shadow/cyclone.c b/cyclone/shadow/cyclone.c index a702074..30f1c84 100644 --- a/cyclone/shadow/cyclone.c +++ b/cyclone/shadow/cyclone.c @@ -1,14 +1,12 @@ -/* Copyright (c) 2003-2004 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. */ /* Never use forked calls in shadow code... */ -/* LATER support multi-atom dir (creation args), and fn ('import' message) - (same in hammer and sickle) */ +/* LATER support multi-atom dir ('cd' message), and fn ('import' message) + (same in maxmode, hammer and sickle) */ -#include -#include #include "m_pd.h" #include "common/loud.h" #include "common/port.h" @@ -22,6 +20,7 @@ typedef struct _cyclone { t_object x_ob; t_symbol *x_dir; + t_symbol *x_canvasdir; t_hammerfile *x_filehandle; } t_cyclone; @@ -29,11 +28,8 @@ static t_class *cyclone_class; static int cyclone_hammerndx; static int cyclone_sicklendx; static int cyclone_nettlesndx; -static int cyclone_dummiesndx; static int cyclone_lastndx; -static t_pd *cyclone_dproxy = 0; - static void cyclone_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) { import_max(fn->s_name, ""); @@ -41,7 +37,8 @@ static void cyclone_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) static void cyclone_doimport(t_cyclone *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 @@ -59,42 +56,28 @@ static void cyclone_import(t_cyclone *x, t_symbol *fn) cyclone_doimport(x, fn, 0); } -static void cyclone_bang(t_cyclone *x) +static void cyclone_cd(t_cyclone *x, t_symbol *dir) { - int i; - fragile_class_printnames("hammer classes are: ", - cyclone_hammerndx, cyclone_sicklendx - 1); - fragile_class_printnames("sickle classes are: ", - cyclone_sicklendx, cyclone_nettlesndx - 1); - fragile_class_printnames("nettles are: ", - cyclone_nettlesndx, cyclone_dummiesndx - 1); - if (cyclone_dproxy) - pd_bang(cyclone_dproxy); - else - post("no replacement abstractions"); - if (cyclone_lastndx > cyclone_dummiesndx) - post("send 'dummies' message to see the list of %d dummy classes", - /* cyclone_lastndx points to the "_dummy" sentinel class */ - cyclone_lastndx - cyclone_dummiesndx); - else - post("no dummies"); + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); } -static void cyclone_reps(t_cyclone *x) +static void cyclone_pwd(t_cyclone *x) { - if (cyclone_dproxy) - typedmess(cyclone_dproxy, gensym("reps"), 0, 0); - else - post("no replacement abstractions"); + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); } -static void cyclone_dummies(t_cyclone *x) +static void cyclone_bang(t_cyclone *x) { - if (cyclone_lastndx > cyclone_dummiesndx) - fragile_class_printnames("dummies are: ", - cyclone_dummiesndx, cyclone_lastndx); - else - post("no dummies"); + if (cyclone_hammerndx && cyclone_sicklendx) + { + fragile_class_printnames("hammer classes are: ", + cyclone_hammerndx, cyclone_sicklendx - 1); + fragile_class_printnames("sickle classes are: ", + cyclone_sicklendx, cyclone_nettlesndx - 1); + } + fragile_class_printnames("nettles are: ", + cyclone_nettlesndx, cyclone_lastndx - 1); } static void cyclone_free(t_cyclone *x) @@ -102,26 +85,20 @@ static void cyclone_free(t_cyclone *x) hammerfile_free(x->x_filehandle); } -static void *cyclone_new(t_symbol *s) +static void *cyclone_new(void) { t_cyclone *x = (t_cyclone *)pd_new(cyclone_class); x->x_filehandle = hammerfile_new((t_pd *)x, 0, cyclone_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); } void cyclone_setup(void) { - int hresult, sresult, dresult; - hresult = sresult = dresult = LOADER_OK; - if (canvas_getcurrent()) - { - /* Loading the library by object creation is banned, because of a danger - of having some of the classes already loaded. LATER rethink. */ - loud_error(0, "apparently an attempt to create a 'cyclone' object"); - loud_errand(0, "without having cyclone library preloaded"); - return; - } + int hresult, sresult; + hresult = sresult = LOADER_OK; if (zgetfn(&pd_objectmaker, gensym("cyclone"))) { loud_error(0, "cyclone is already loaded"); @@ -132,12 +109,12 @@ void cyclone_setup(void) cyclone_class = class_new(gensym("cyclone"), (t_newmethod)cyclone_new, (t_method)cyclone_free, - sizeof(t_cyclone), 0, A_DEFSYM, 0); + sizeof(t_cyclone), 0, 0); class_addbang(cyclone_class, cyclone_bang); - class_addmethod(cyclone_class, (t_method)cyclone_reps, - gensym("reps"), 0); - class_addmethod(cyclone_class, (t_method)cyclone_dummies, - gensym("dummies"), 0); + class_addmethod(cyclone_class, (t_method)cyclone_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(cyclone_class, (t_method)cyclone_pwd, + gensym("pwd"), 0); class_addmethod(cyclone_class, (t_method)cyclone_import, gensym("import"), A_DEFSYM, 0); class_addmethod(cyclone_class, (t_method)cyclone_click, @@ -145,49 +122,42 @@ void cyclone_setup(void) A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); hammerfile_setup(cyclone_class, 0); - cyclone_hammerndx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("hammer"))) - loud_warning(0, "cyclone", "hammer is already loaded"); - else - hresult = unstable_load_lib("", "hammer"); - - cyclone_sicklendx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("sickle"))) - loud_warning(0, "cyclone", "sickle is already loaded"); + if (canvas_getcurrent()) + { + /* Loading hammer and sickle by cyclone object creation is banned, + because of a danger of having some of the classes already loaded. */ + loud_warning(0, "cyclone", + "creating cyclone object without loading cyclone components"); + cyclone_hammerndx = cyclone_sicklendx = 0; + } else - sresult = unstable_load_lib("", "sickle"); + { + cyclone_hammerndx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("hammer"))) + loud_warning(0, "cyclone", "hammer is already loaded"); + else + hresult = unstable_load_lib("", "hammer"); + cyclone_sicklendx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("sickle"))) + loud_warning(0, "cyclone", "sickle is already loaded"); + else + sresult = unstable_load_lib("", "sickle"); + } cyclone_nettlesndx = fragile_class_count(); allnettles_setup(); - - cyclone_dummiesndx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("dummies"))) - loud_warning(0, "cyclone", "dummies are already loaded"); - else - dresult = unstable_load_lib("", "dummies"); - cyclone_lastndx = fragile_class_count() - 1; if (hresult == LOADER_NOFILE) loud_error(0, "hammer library is missing"); else if (sresult == LOADER_NOFILE) loud_error(0, "sickle library is missing"); - else if (!zgetfn(&pd_objectmaker, gensym("hammer")) || - !zgetfn(&pd_objectmaker, gensym("sickle"))) + else if (cyclone_hammerndx && + (!zgetfn(&pd_objectmaker, gensym("hammer")) || + !zgetfn(&pd_objectmaker, gensym("sickle")))) { loud_error(0, "version mismatch"); loud_errand(0, "use a more recent Pd release (or recompile the cyclone)."); } - else if (dresult == LOADER_NOFILE) - loud_warning(0, "cyclone", "dummies not found"); - else - { - t_symbol *s = gensym("_cc.dummies"); - if (s->s_thing && !s->s_next - && !strcmp(class_getname(*s->s_thing), "_cc.dummies")) - cyclone_dproxy = s->s_thing; - else - bug("cyclone_setup"); /* FIXME */ - } } diff --git a/cyclone/shadow/dummies.c b/cyclone/shadow/dummies.c index 0a3c218..5ad7cc1 100644 --- a/cyclone/shadow/dummies.c +++ b/cyclone/shadow/dummies.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2004 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. */ @@ -554,7 +554,7 @@ static t_object *dummy_newobject(t_symbol *s, t_dummy_slot **slotp) x = (t_object *)pd_new(dummy_classes[fnd]); sl = &dummy_slots[fnd]; if (fnd == dummy_nclasses) - bug("dummy_newobject"); /* create a "_dummy" in this case */ + loudbug_bug("dummy_newobject"); /* create a "_dummy" in this case */ else if (!sl->s_warned) { loud_warning((t_pd *)x, 0, "dummy substitution"); @@ -565,15 +565,6 @@ static t_object *dummy_newobject(t_symbol *s, t_dummy_slot **slotp) } static void ccdummies_bang(t_pd *x) -{ - if (dummy_nreps) - post("send 'reps' message to see the list of %d \ -replacement abstractions", dummy_nreps); - else - post("no replacement abstractions"); -} - -static void ccdummies_reps(t_pd *x) { if (dummy_nreps) { @@ -619,8 +610,9 @@ void dummies_setup(void) ndoomed++; else if (ndoomed && i < dummy_nclasses - 1) { - bug("dummies_setup"); - post("(\"%s\": clashing or doomed dummy not registered for import)", + loudbug_bug("dummies_setup"); + loudbug_post + ("(\"%s\": clashing or doomed dummy not registered for import)", sl->s_name); } if ((fd = open_via_path("", sl->s_name, ".pd", @@ -643,7 +635,5 @@ void dummies_setup(void) ccdummies_class = class_new(gensym("_cc.dummies"), 0, 0, sizeof(t_pd), CLASS_PD | CLASS_NOINLET, 0); class_addbang(ccdummies_class, ccdummies_bang); - class_addmethod(ccdummies_class, (t_method)ccdummies_reps, - gensym("reps"), 0); pd_bind(pd_new(ccdummies_class), gensym("_cc.dummies")); /* never freed */ } diff --git a/cyclone/shadow/maxmode.c b/cyclone/shadow/maxmode.c index f90d990..9cd1055 100644 --- a/cyclone/shadow/maxmode.c +++ b/cyclone/shadow/maxmode.c @@ -1,21 +1,180 @@ -/* Copyright (c) 2004 krzYszcz and others. +/* Copyright (c) 2004-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 +#include #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" +#include "common/port.h" +#include "hammer/file.h" +#include "unstable/fragile.h" #include "unstable/loader.h" +#include "../build_counter" + +typedef struct _maxmode +{ + t_object x_ob; + t_symbol *x_dir; + t_symbol *x_canvasdir; + t_hammerfile *x_filehandle; +} t_maxmode; + +static t_class *maxmode_class; +static int maxmode_dummiesndx; +static int maxmode_lastndx; +static t_pd *maxmode_dproxy = 0; +static int maxmode_withbanner = 0; + +static void maxmode_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) +{ + import_max(fn->s_name, ""); +} + +static void maxmode_doimport(t_maxmode *x, t_symbol *fn, t_symbol *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 + hammerpanel_open(x->x_filehandle, dir); +} + +static void maxmode_click(t_maxmode *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + maxmode_doimport(x, 0, 0); +} + +static void maxmode_import(t_maxmode *x, t_symbol *fn) +{ + maxmode_doimport(x, fn, 0); +} + +static void maxmode_cd(t_maxmode *x, t_symbol *dir) +{ + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); +} + +static void maxmode_pwd(t_maxmode *x) +{ + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); +} + +static void maxmode_bang(t_maxmode *x) +{ + if (maxmode_dproxy) + pd_bang(maxmode_dproxy); + else + post("no replacement abstractions"); + if (maxmode_lastndx > maxmode_dummiesndx) + fragile_class_printnames("dummies are: ", + maxmode_dummiesndx, maxmode_lastndx); + else + post("no dummies"); +} + +static void maxmode_free(t_maxmode *x) +{ + hammerfile_free(x->x_filehandle); +} + +static void *maxmode_new(t_symbol *s, int ac, t_atom *av) +{ + t_maxmode *x = (t_maxmode *)pd_new(maxmode_class); + if (maxmode_withbanner && !ac) + { + post("this is maxmode %s, %s %s build", + CYCLONE_VERSION, loud_ordinal(CYCLONE_BUILD), CYCLONE_RELEASE); + loud_warning(0, "maxmode", + "creating maxmode object without loading cyclone components"); + maxmode_withbanner = 0; + } + if (!fittermax_get()) + { + int selective = 0; + if (ac) + { + while (ac--) if (av->a_type == A_SYMBOL) + { + /* FIXME register into fitter for per-patch, selective + compatibility control */ + av++; + } + } + if (!selective) + fittermax_set(); + } + x->x_filehandle = hammerfile_new((t_pd *)x, 0, maxmode_readhook, 0, 0); + 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); +} void maxmode_setup(void) { - shared_setmaxcompatibility(); - if (zgetfn(&pd_objectmaker, gensym("cyclone"))) - loud_warning(0, "maxmode", "cyclone is already loaded"); + int dresult = LOADER_OK; + if (zgetfn(&pd_objectmaker, gensym("maxmode"))) + { + loud_error(0, "maxmode is already loaded"); + return; + } + maxmode_class = class_new(gensym("maxmode"), + (t_newmethod)maxmode_new, + (t_method)maxmode_free, + sizeof(t_maxmode), 0, A_GIMME, 0); + class_addbang(maxmode_class, maxmode_bang); + class_addmethod(maxmode_class, (t_method)maxmode_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(maxmode_class, (t_method)maxmode_pwd, + gensym("pwd"), 0); + class_addmethod(maxmode_class, (t_method)maxmode_import, + gensym("import"), A_DEFSYM, 0); + class_addmethod(maxmode_class, (t_method)maxmode_click, + gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + hammerfile_setup(maxmode_class, 0); + + if (canvas_getcurrent()) + { + fitter_setup(0, 0, 0); + if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) + /* cycloneless maxmode -- banner is posted by the oldest + maxmode object with no creation arguments */ + maxmode_withbanner = 1; + } + else + { + fittermax_set(); + if (zgetfn(&pd_objectmaker, gensym("cyclone"))) + loud_warning(0, "maxmode", "cyclone is already loaded"); + else + { + if (unstable_load_lib("", "cyclone") == LOADER_NOFILE) + loud_error(0, "cyclone library is missing"); + else if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) + loud_error(0, "miXed/Pd version mismatch"); + } + } + maxmode_dummiesndx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("dummies"))) + loud_warning(0, "maxmode", "dummies are already loaded"); + else + dresult = unstable_load_lib("", "dummies"); + maxmode_lastndx = fragile_class_count() - 1; + if (dresult == LOADER_NOFILE) + loud_warning(0, "maxmode", "dummies not found"); else { - if (unstable_load_lib("", "cyclone") == LOADER_NOFILE) - loud_error(0, "cyclone library is missing"); - else if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) - loud_error(0, "miXed/Pd version mismatch"); + t_symbol *s = gensym("_cc.dummies"); + if (s->s_thing && !s->s_next + && !strcmp(class_getname(*s->s_thing), "_cc.dummies")) + maxmode_dproxy = s->s_thing; + else + loudbug_bug("maxmode_setup"); /* FIXME */ } } diff --git a/cyclone/sickle/Line.c b/cyclone/sickle/Line.c index 20a81d2..eb8be26 100644 --- a/cyclone/sickle/Line.c +++ b/cyclone/sickle/Line.c @@ -53,10 +53,10 @@ static void line_tick(t_line *x) { outlet_bang(x->x_bangout); #ifdef LINE_DEBUG - post("exit point %d, after %d retarget calls", - x->dbg_exitpoint, x->dbg_nretargets); - post("at value %g, after last %d npoints, with inc %g, biginc %g", - x->x_value, x->dbg_npoints, x->x_inc, x->x_biginc); + loudbug_post("exit point %d, after %d retarget calls", + x->dbg_exitpoint, x->dbg_nretargets); + loudbug_post("at value %g, after last %d npoints, with inc %g, biginc %g", + x->x_value, x->dbg_npoints, x->x_inc, x->x_biginc); x->dbg_nretargets = x->dbg_exitpoint = x->dbg_npoints = 0; #endif } @@ -221,7 +221,7 @@ static void line_list(t_line *x, t_symbol *s, int ac, t_atom *av) } x->x_nsegs = nsegs; #ifdef LINE_DEBUG - post("%d segments:", x->x_nsegs); + loudbug_post("%d segments:", x->x_nsegs); #endif segp = x->x_segs; if (odd) nsegs--; @@ -230,7 +230,7 @@ static void line_list(t_line *x, t_symbol *s, int ac, t_atom *av) segp->s_target = av++->a_w.w_float; segp->s_delta = av++->a_w.w_float; #ifdef LINE_DEBUG - post("%g %g", segp->s_target, segp->s_delta); + loudbug_post("%g %g", segp->s_target, segp->s_delta); #endif segp++; } @@ -239,7 +239,7 @@ static void line_list(t_line *x, t_symbol *s, int ac, t_atom *av) segp->s_target = av->a_w.w_float; segp->s_delta = 0; #ifdef LINE_DEBUG - post("%g %g", segp->s_target, segp->s_delta); + loudbug_post("%g %g", segp->s_target, segp->s_delta); #endif } x->x_deltaset = 0; diff --git a/cyclone/sickle/Makefile.objects b/cyclone/sickle/Makefile.objects index 4528d83..1d80296 100644 --- a/cyclone/sickle/Makefile.objects +++ b/cyclone/sickle/Makefile.objects @@ -4,6 +4,7 @@ unstable/fragile.o \ unstable/fringe.o \ common/loud.o \ common/grow.o \ +common/fitter.o \ common/vefl.o \ common/clc.o \ common/lex.o \ diff --git a/cyclone/sickle/Scope.c b/cyclone/sickle/Scope.c index adc4888..8a71cb5 100644 --- a/cyclone/sickle/Scope.c +++ b/cyclone/sickle/Scope.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. */ @@ -16,6 +16,7 @@ #include "g_canvas.h" #include "common/loud.h" #include "common/grow.h" +#include "common/fitter.h" #include "unstable/forky.h" #include "sickle/sic.h" @@ -320,7 +321,7 @@ static t_canvas *scope_getcanvas(t_scope *x, t_glist *glist) { if (glist != x->x_glist) { - bug("scope_getcanvas"); + loudbug_bug("scope_getcanvas"); x->x_glist = glist; } return (x->x_canvas = glist_getcanvas(glist)); @@ -338,8 +339,12 @@ static void scope_period(t_scope *x, t_symbol *s, int ac, t_atom *av) int result = loud_floatarg(*(t_pd *)x, (s ? 0 : 2), ac, av, &period, SCOPE_MINPERIOD, SCOPE_MAXPERIOD, /* LATER rethink warning rules */ - (s ? LOUD_CLIP : LOUD_CLIP | LOUD_WARN), - (s ? 0 : LOUD_WARN), "samples per element"); + (s ? LOUD_CLIP : LOUD_CLIP | LOUD_WARN), 0, + "samples per element"); + if (!s && result == LOUD_ARGOVER) + fittermax_warning(*(t_pd *)x, + "more than %g samples per element requested", + SCOPE_MAXPERIOD); if (!s || result == LOUD_ARGOK || result == LOUD_ARGOVER) { x->x_period = (int)period; @@ -360,14 +365,18 @@ static void scope_bufsize(t_scope *x, t_symbol *s, int ac, t_atom *av) int result = loud_floatarg(*(t_pd *)x, (s ? 0 : 4), ac, av, &bufsize, SCOPE_MINBUFSIZE, SCOPE_WARNBUFSIZE, /* LATER rethink warning rules */ - (s ? LOUD_CLIP : LOUD_CLIP | LOUD_WARN), - (s ? 0 : LOUD_WARN), "display elements"); + (s ? LOUD_CLIP : LOUD_CLIP | LOUD_WARN), 0, + "display elements"); if (result == LOUD_ARGOVER) { bufsize = (s ? x->x_bufsize : SCOPE_DEFBUFSIZE); result = loud_floatarg(*(t_pd *)x, (s ? 0 : 4), ac, av, &bufsize, 0, SCOPE_MAXBUFSIZE, 0, LOUD_CLIP | LOUD_WARN, "display elements"); + if (!s && result == LOUD_ARGOK) + fittermax_warning(*(t_pd *)x, + "more than %g display elements requested", + SCOPE_WARNBUFSIZE); } if (!s) { @@ -1042,4 +1051,5 @@ void Scope_tilde_setup(void) gensym("_click"), A_FLOAT, 0); class_addmethod(scopehandle_class, (t_method)scopehandle__motionhook, gensym("_motion"), A_FLOAT, A_FLOAT, 0); + fitter_setup(scope_class, 0, 0); } diff --git a/cyclone/sickle/average.c b/cyclone/sickle/average.c index ea330c1..74adfc8 100644 --- a/cyclone/sickle/average.c +++ b/cyclone/sickle/average.c @@ -7,6 +7,7 @@ #include #include "m_pd.h" +#include "common/loud.h" #include "sickle/sic.h" #if defined(NT) || defined(MACOSX) @@ -74,7 +75,7 @@ static void average_setmode(t_average *x, int mode) x->x_sumfn = average_rmssum; else { - bug("average_setmode"); + loudbug_bug("average_setmode"); return; } x->x_mode = mode; diff --git a/cyclone/sickle/bitshift.c b/cyclone/sickle/bitshift.c index 28ee744..707048c 100644 --- a/cyclone/sickle/bitshift.c +++ b/cyclone/sickle/bitshift.c @@ -8,6 +8,7 @@ more generic (use long long values?) */ #include "m_pd.h" +#include "common/loud.h" #include "sickle/sic.h" #ifdef KRZYSZCZ @@ -91,8 +92,8 @@ static void bitshift_shift(t_bitshift *x, t_floatarg f) if (i > 0) { #ifdef BITSHIFT_DEBUG - post("%.8x << %d == %.8x, %.8x << %d == %.8x", - 1, i, 1 << i, -1, i, -1 << i); + loudbug_post("%.8x << %d == %.8x, %.8x << %d == %.8x", + 1, i, 1 << i, -1, i, -1 << i); #endif if (i < nbits) x->x_lshift = i; @@ -102,8 +103,8 @@ static void bitshift_shift(t_bitshift *x, t_floatarg f) else if (i < 0) { #ifdef BITSHIFT_DEBUG - post("%.8x >> %d == %.8x, %.8x >> %d == %.8x", - 0x7fffffff, -i, 0x7fffffff >> -i, -1, -i, -1 >> -i); + loudbug_post("%.8x >> %d == %.8x, %.8x >> %d == %.8x", + 0x7fffffff, -i, 0x7fffffff >> -i, -1, -i, -1 >> -i); #endif x->x_rshift = (i <= -nbits ? nbits - 1 : -i); } diff --git a/cyclone/sickle/buffir.c b/cyclone/sickle/buffir.c index ee42af9..1fd9d23 100644 --- a/cyclone/sickle/buffir.c +++ b/cyclone/sickle/buffir.c @@ -1,10 +1,11 @@ -/* 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. */ #include #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" #include "sickle/sic.h" #include "sickle/arsic.h" @@ -38,14 +39,11 @@ static void buffir_setrange(t_buffir *x, t_floatarg f1, t_floatarg f2) { int newsize, pos = x->x_lohead - x->x_histlo; int oldbytes = x->x_histsize * sizeof(*x->x_histlo); - if (shared_getmaxcompatibility()) + static int warned = 0; + if (fittermax_get() && !warned) { - static int warned = 0; - if (!warned) - { - loud_incompatible(buffir_class, "stretching history buffer"); - warned = 1; - } + fittermax_warning(buffir_class, "stretching history buffer"); + warned = 1; } newsize = x->x_histsize * 2; while (newsize < siz) newsize *= 2; @@ -197,7 +195,6 @@ static void *buffir_new(t_symbol *s, t_floatarg f1, t_floatarg f2) x->x_histlo = x->x_histini; buffir_clear(x); buffir_setrange(x, f1, f2); - shared_usecompatibility(); } return (x); } @@ -214,4 +211,5 @@ void buffir_tilde_setup(void) gensym("clear"), 0); class_addmethod(buffir_class, (t_method)buffir_set, gensym("set"), A_SYMBOL, A_DEFFLOAT, A_DEFFLOAT, 0); + fitter_setup(buffir_class, 0, 0); } diff --git a/cyclone/sickle/curve.c b/cyclone/sickle/curve.c index 78f1427..730dd0d 100644 --- a/cyclone/sickle/curve.c +++ b/cyclone/sickle/curve.c @@ -71,8 +71,8 @@ static void curve_cc(t_curve *x, t_curveseg *segp, float f) segp->s_nhops = (nhops > 0 ? nhops : 0); clccurve_coefs(segp->s_nhops, (double)f, &segp->s_bb, &segp->s_mm); #ifdef CURVE_DEBUG - post("%g %g %g %g", - segp->s_target, segp->s_delta, segp->s_bb, segp->s_mm); + loudbug_post("%g %g %g %g", + segp->s_target, segp->s_delta, segp->s_bb, segp->s_mm); #endif } @@ -80,10 +80,10 @@ static void curve_tick(t_curve *x) { outlet_bang(x->x_bangout); #ifdef CURVE_DEBUG - post("exit point %d, after %d retarget calls", - x->dbg_exitpoint, x->dbg_nretargets); - post("at value %g, after last %d nhops, with bb %g, mm %g", - x->x_value, x->dbg_nhops, x->x_bb, x->x_mm); + loudbug_post("exit point %d, after %d retarget calls", + x->dbg_exitpoint, x->dbg_nretargets); + loudbug_post("at value %g, after last %d nhops, with bb %g, mm %g", + x->x_value, x->dbg_nhops, x->x_bb, x->x_mm); x->dbg_nretargets = x->dbg_exitpoint = x->dbg_nhops = 0; #endif } @@ -223,7 +223,7 @@ static void curve_float(t_curve *x, t_float f) x->x_curseg->s_target = f; x->x_curseg->s_delta = x->x_delta; #ifdef CURVE_DEBUG - startpost("single segment: "); + loudbug_startpost("single segment: "); #endif curve_cc(x, x->x_curseg, x->x_ccinput); x->x_retarget = 1; @@ -278,7 +278,7 @@ static void curve_list(t_curve *x, t_symbol *s, int ac, t_atom *av) } x->x_nsegs = nsegs; #ifdef CURVE_DEBUG - post("%d segments:", x->x_nsegs); + loudbug_post("%d segments:", x->x_nsegs); #endif segp = x->x_segs; if (odd) nsegs--; diff --git a/cyclone/sickle/cycle.c b/cyclone/sickle/cycle.c index 01500ba..8daa43e 100644 --- a/cyclone/sickle/cycle.c +++ b/cyclone/sickle/cycle.c @@ -135,7 +135,7 @@ static void *cycle_new(t_symbol *s, int ac, t_atom *av) x->x_costable = sic_makecostable(&tabsize); if (tabsize != CYCLE_TABSIZE) { - bug("cycle_new"); + loudbug_bug("cycle_new"); pd_free((t_pd *)x); return (0); } diff --git a/cyclone/sickle/pong.c b/cyclone/sickle/pong.c index 2878842..5c5e143 100644 --- a/cyclone/sickle/pong.c +++ b/cyclone/sickle/pong.c @@ -5,6 +5,7 @@ /* CHECKED whatever args, there are always 3 inlets (refman's rubbish) */ #include "m_pd.h" +#include "common/loud.h" #include "unstable/forky.h" #include "sickle/sic.h" @@ -214,7 +215,7 @@ static void pong_dsp(t_pong *x, t_signal **sp) else { #ifdef PONG_DEBUG - post("using pong_perform_nofeeders"); + loudbug_post("using pong_perform_nofeeders"); #endif dsp_add(pong_perform_nofeeders, 6, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec); diff --git a/cyclone/sickle/sickle.c b/cyclone/sickle/sickle.c index 807c2ad..1d46050 100644 --- a/cyclone/sickle/sickle.c +++ b/cyclone/sickle/sickle.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 #include "m_pd.h" #include "unstable/fragile.h" #include "common/loud.h" @@ -15,6 +14,7 @@ typedef struct _sickle { t_object x_ob; t_symbol *x_dir; + t_symbol *x_canvasdir; t_hammerfile *x_filehandle; } t_sickle; @@ -29,7 +29,8 @@ static void sickle_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) static void sickle_doimport(t_sickle *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 sickle_import(t_sickle *x, t_symbol *fn) sickle_doimport(x, fn, 0); } +static void sickle_cd(t_sickle *x, t_symbol *dir) +{ + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); +} + +static void sickle_pwd(t_sickle *x) +{ + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); +} + static void sickle_bang(t_sickle *x) { fragile_class_printnames("sickle classes are: ", @@ -58,11 +70,13 @@ static void sickle_free(t_sickle *x) hammerfile_free(x->x_filehandle); } -static void *sickle_new(t_symbol *s) +static void *sickle_new(void) { t_sickle *x = (t_sickle *)pd_new(sickle_class); x->x_filehandle = hammerfile_new((t_pd *)x, 0, sickle_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 sickle_setup(void) sickle_class = class_new(gensym("sickle"), (t_newmethod)sickle_new, (t_method)sickle_free, - sizeof(t_sickle), 0, A_DEFSYM, 0); + sizeof(t_sickle), 0, 0); class_addbang(sickle_class, sickle_bang); + class_addmethod(sickle_class, (t_method)sickle_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(sickle_class, (t_method)sickle_pwd, + gensym("pwd"), 0); class_addmethod(sickle_class, (t_method)sickle_import, gensym("import"), A_DEFSYM, 0); class_addmethod(sickle_class, (t_method)sickle_click, diff --git a/cyclone/sickle/svf.c b/cyclone/sickle/svf.c index 0909571..5bc0458 100644 --- a/cyclone/sickle/svf.c +++ b/cyclone/sickle/svf.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. */ @@ -23,11 +23,13 @@ #define SVF_LINEAR 1 #define SVF_RADIANS 2 #define SVF_DRIVE .0001 -#define SVF_QSTRETCH 1.2 /* CHECKED */ -#define SVF_MINR 0. /* CHECKME */ -#define SVF_MAXR 1.2 /* CHECKME */ -#define SVF_MINOMEGA 0. /* CHECKME */ +#define SVF_QSTRETCH 1.2 /* CHECKED */ +#define SVF_MINR 0. /* CHECKME */ +#define SVF_MAXR 1.2 /* CHECKME */ +#define SVF_MINOMEGA 0. /* CHECKME */ #define SVF_MAXOMEGA (SHARED_PI * .5) /* CHECKME */ +#define SVF_DEFFREQ 0. +#define SVF_DEFQ .01 /* CHECKME */ typedef struct _svf { @@ -125,25 +127,43 @@ static void svf_dsp(t_svf *x, t_signal **sp) sp[4]->s_vec, sp[5]->s_vec, sp[6]->s_vec); } -static void *svf_new(t_symbol *s, t_floatarg f1, t_floatarg f2) +static void *svf_new(t_symbol *s, int ac, t_atom *av) { t_svf *x = (t_svf *)pd_new(svf_class); + t_float freq = SVF_DEFFREQ, qcoef = SVF_DEFQ; + t_symbol *modesym = 0; + int i; + for (i = 0; i < ac; i++) if (av[i].a_type == A_SYMBOL) + { + modesym = av[i].a_w.w_symbol; + break; + } + while (ac && av->a_type != A_FLOAT) ac--, av++; + if (ac) + { + freq = av->a_w.w_float; + ac--; av++; + while (ac && av->a_type != A_FLOAT) ac--, av++; + if (ac) + qcoef = av->a_w.w_float; + } x->x_srcoef = SHARED_PI / sys_getsr(); - sic_newinlet((t_sic *)x, f1); - sic_newinlet((t_sic *)x, f2); + sic_newinlet((t_sic *)x, freq); + sic_newinlet((t_sic *)x, qcoef); outlet_new((t_object *)x, &s_signal); outlet_new((t_object *)x, &s_signal); outlet_new((t_object *)x, &s_signal); outlet_new((t_object *)x, &s_signal); svf_clear(x); - if (s == ps_linear) + if (modesym == ps_linear) x->x_mode = SVF_LINEAR; - else if (s == ps_radians) + else if (modesym == ps_radians) x->x_mode = SVF_RADIANS; else { x->x_mode = SVF_HZ; - if (s && s != &s_ && s != ps_hz && s != gensym("Hz")) + if (modesym && modesym != &s_ && + modesym != ps_hz && modesym != gensym("Hz")) { /* CHECKED no warning */ } @@ -158,8 +178,7 @@ void svf_tilde_setup(void) ps_radians = gensym("radians"); svf_class = class_new(gensym("svf~"), (t_newmethod)svf_new, 0, - sizeof(t_svf), 0, - A_DEFFLOAT, A_DEFFLOAT, A_DEFSYM, 0); + sizeof(t_svf), 0, A_GIMME, 0); sic_setup(svf_class, svf_dsp, SIC_FLOATTOSIGNAL); class_addmethod(svf_class, (t_method)svf_clear, gensym("clear"), 0); class_addmethod(svf_class, (t_method)svf_hz, ps_hz, 0); diff --git a/shared/Makefile.dirs b/shared/Makefile.dirs index 5764f41..0d88ac0 100644 --- a/shared/Makefile.dirs +++ b/shared/Makefile.dirs @@ -1 +1 @@ -MIXED_DIRS = common hammer sickle toxy unstable +MIXED_DIRS = common hammer sickle toxy xeq unstable diff --git a/shared/common/Makefile.sources b/shared/common/Makefile.sources index 18847a5..f605df4 100644 --- a/shared/common/Makefile.sources +++ b/shared/common/Makefile.sources @@ -3,6 +3,7 @@ binport.c \ clc.c \ dict.c \ fi.c \ +fitter.c \ grow.c \ lex.c \ loud.c \ diff --git a/shared/common/clc.c b/shared/common/clc.c index b4d1208..28244f5 100644 --- a/shared/common/clc.c +++ b/shared/common/clc.c @@ -3,6 +3,7 @@ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include +#include "clc.h" /* Problem: find a function f : p -> q (where p is user's curve control parameter, q is log factor) such that the curves will bend in diff --git a/shared/common/dict.c b/shared/common/dict.c index f2dd838..19d8b2e 100644 --- a/shared/common/dict.c +++ b/shared/common/dict.c @@ -8,7 +8,7 @@ #include #include #include "m_pd.h" -#include "common/dict.h" +#include "dict.h" #ifdef KRZYSZCZ //#define DICT_DEBUG diff --git a/shared/common/fitter.c b/shared/common/fitter.c new file mode 100644 index 0000000..2ccdd53 --- /dev/null +++ b/shared/common/fitter.c @@ -0,0 +1,195 @@ +/* Copyright (c) 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 +#include +#include +#include "m_pd.h" +#include "fitter.h" + +#ifdef KRZYSZCZ +# include "loud.h" +# define FITTER_DEBUG +#else +# define loudbug_bug(msg) fprintf(stderr, "BUG: %s\n", msg), bug(msg) +#endif + +/* FIXME compatibility mode should be a standard Pd feature. When it is, + it will be possible to simplify the implementation. Until then, + we have to handle multiple copies of the 'fittermode_value' variable + (coming from different externals), and the only way is multicasting + through a symbol (#compatibility). */ +static t_symbol *fittermode_value = 0; + +typedef struct _fittermode_client +{ + t_class *fc_owner; + t_symbol **fc_mirror; + t_fittermode_callback fc_callback; + struct _fittermode_client *fc_next; +} t_fittermode_client; + +static t_fittermode_client *fittermode_clients = 0; +static t_class *fittermode_class = 0; +static t_pd *fittermode_target = 0; +static int fittermode_ready = 0; +static t_symbol *fitterps_hashcompatibility = 0; +static t_symbol *fitterps_max = 0; + +/* read access (query), only from fittermode_dosetup() */ +static void fittermode_bang(t_pd *x) +{ + if (fitterps_hashcompatibility) + { + if (fittermode_ready /* do not reply to own request */ + && fitterps_hashcompatibility->s_thing) + /* this proliferates for the third and subsequent + fittermode_dosetup() calls... */ + pd_symbol(fitterps_hashcompatibility->s_thing, + fittermode_value); + } + else loudbug_bug("fittermode_bang"); +} + +/* read access (reply), only from fitter_dosetup() */ +static void fittermode_symbol(t_pd *x, t_symbol *s) +{ + fittermode_value = s; +} + +/* write access, only from fitter_setmode() */ +static void fittermode_set(t_pd *x, t_symbol *s) +{ + t_fittermode_client *fc; + fittermode_value = s; + for (fc = fittermode_clients; fc; fc = fc->fc_next) + { + if (fc->fc_mirror) + *fc->fc_mirror = s; + if (fc->fc_callback) + fc->fc_callback(s); + } +} + +static void fittermode_dosetup(int noquery) +{ + if (fittermode_class || fittermode_target) + loudbug_bug("fittermode_dosetup"); + fitterps_hashcompatibility = gensym("#compatibility"); + fitterps_max = gensym("max"); + fittermode_class = class_new(fitterps_hashcompatibility, + 0, 0, sizeof(t_pd), + CLASS_PD | CLASS_NOINLET, 0); + class_addbang(fittermode_class, fittermode_bang); + class_addsymbol(fittermode_class, fittermode_symbol); + class_addmethod(fittermode_class, + (t_method)fittermode_set, + gensym("set"), A_SYMBOL, 0); + fittermode_target = pd_new(fittermode_class); + pd_bind(fittermode_target, fitterps_hashcompatibility); + if (!noquery) + pd_bang(fitterps_hashcompatibility->s_thing); + fittermode_ready = 1; +} + +void fitter_setup(t_class *owner, t_symbol **mirror, + t_fittermode_callback callback) +{ + if (!fittermode_class) + fittermode_dosetup(0); + if (mirror || callback) + { + t_fittermode_client *fc = getbytes(sizeof(*fc)); + fc->fc_owner = owner; + fc->fc_mirror = mirror; + fc->fc_callback = callback; + fc->fc_next = fittermode_clients; + fittermode_clients = fc; + if (mirror) + *mirror = fittermode_value; + } +} + +void fitter_drop(t_class *owner) +{ + if (fittermode_class && fitterps_hashcompatibility->s_thing) + { + t_fittermode_client *fcp = 0, + *fc = fittermode_clients; + while (fc) + { + if (fc->fc_owner == owner) + { + if (fcp) + fcp->fc_next = fc->fc_next; + else + fittermode_clients = fc->fc_next; + break; + } + fcp = fc; + fc = fc->fc_next; + } + if (fc) + freebytes(fc, sizeof(*fc)); + else + loudbug_bug("fitter_drop 1"); + } + else loudbug_bug("fitter_drop 2"); +} + +void fitter_setmode(t_symbol *s) +{ + post("setting compatibility mode to '%s'", (s ? s->s_name : "none")); + if (!fittermode_class) + fittermode_dosetup(1); + if (fitterps_hashcompatibility->s_thing) + { + t_atom at; + SETSYMBOL(&at, s); + typedmess(fitterps_hashcompatibility->s_thing, gensym("set"), 1, &at); + } + else loudbug_bug("fitter_setmode"); +} + +t_symbol *fitter_getmode(void) +{ + if (!fittermode_class) + fittermode_dosetup(0); + return (fittermode_value); +} + +void fittermax_set(void) +{ + if (!fittermode_class) + fittermode_dosetup(0); + fitter_setmode(fitterps_max); +} + +int fittermax_get(void) +{ + if (!fittermode_class) + fittermode_dosetup(0); + return (fittermode_value == fitterps_max); +} + +void fittermax_warning(t_class *c, char *fmt, ...) +{ + if (!fittermode_class) + fittermode_dosetup(0); + if (fittermode_value == fitterps_max) + { + char buf[MAXPDSTRING]; + va_list ap; + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + post("'%s' class incompatibility warning:\n\t%s", + class_getname(c), buf); + va_end(ap); + } +} + +void fittermax_rangewarning(t_class *c, int maxmax, char *what) +{ + fittermax_warning(c, "more than %d %s requested", maxmax, what); +} diff --git a/shared/common/fitter.h b/shared/common/fitter.h new file mode 100644 index 0000000..3f3303c --- /dev/null +++ b/shared/common/fitter.h @@ -0,0 +1,20 @@ +/* Copyright (c) 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. */ + +#ifndef __FITTER_H__ +#define __FITTER_H__ + +typedef void (*t_fittermode_callback)(t_symbol *s); + +void fitter_setup(t_class *owner, t_symbol **mirror, + t_fittermode_callback callback); +void fitter_drop(t_class *owner); +void fitter_setmode(t_symbol *s); +t_symbol *fitter_getmode(void); +void fittermax_set(void); +int fittermax_get(void); +void fittermax_warning(t_class *c, char *fmt, ...); +void fittermax_rangewarning(t_class *c, int maxmax, char *what); + +#endif diff --git a/shared/common/grow.c b/shared/common/grow.c index f02509a..c67ab50 100644 --- a/shared/common/grow.c +++ b/shared/common/grow.c @@ -6,7 +6,7 @@ #include #include "m_pd.h" -#include "common/grow.h" +#include "grow.h" /* Prior to this call a caller is supposed to check for *nrequested > *sizep. Returns a reallocated buffer's pointer (success) or a given 'bufini' diff --git a/shared/common/lex.c b/shared/common/lex.c index e9fd574..aafed9d 100644 --- a/shared/common/lex.c +++ b/shared/common/lex.c @@ -10,7 +10,7 @@ #else #include "m_pd.h" #endif -#include "common/lex.h" +#include "lex.h" static int lex_nextbyte(t_lex *lx, unsigned char *buf) { diff --git a/shared/common/loud.c b/shared/common/loud.c index 4f64110..6229a77 100644 --- a/shared/common/loud.c +++ b/shared/common/loud.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. */ @@ -7,93 +7,15 @@ #include #include #include "m_pd.h" -#include "common/loud.h" +#include "loud.h" + +#ifdef MSW +#define vsnprintf _vsnprintf +#endif /* The 'shared_' calls do not really belong here, LATER find them a permanent home. */ -/* FIXME compatibility mode should be a standard Pd feature */ -static t_symbol *shared_compatibility = 0; -static t_class *sharedcompatibility_class = 0; -static t_pd *sharedcompatibility_target = 0; -static t_symbol *sharedps_hashcompatibility = 0; -static t_symbol *sharedps_max = 0; - -static void sharedcompatibility_bang(t_pd *x) -{ - if (sharedps_hashcompatibility) - { - if (shared_compatibility && sharedps_hashcompatibility->s_thing) - pd_symbol(sharedps_hashcompatibility->s_thing, - shared_compatibility); - } - else bug("sharedcompatibility_bang"); -} - -static void sharedcompatibility_symbol(t_pd *x, t_symbol *s) -{ - shared_compatibility = s; -} - -static void sharedcompatibility_setup(t_symbol *s) -{ - if (sharedcompatibility_class || sharedcompatibility_target) - bug("sharedcompatibility_setup"); - sharedps_hashcompatibility = gensym("#compatibility"); - sharedps_max = gensym("max"); - sharedcompatibility_class = class_new(sharedps_hashcompatibility, - 0, 0, sizeof(t_pd), - CLASS_PD | CLASS_NOINLET, 0); - class_addbang(sharedcompatibility_class, sharedcompatibility_bang); - class_addsymbol(sharedcompatibility_class, sharedcompatibility_symbol); - sharedcompatibility_target = pd_new(sharedcompatibility_class); - pd_bind(sharedcompatibility_target, sharedps_hashcompatibility); - if (s) - pd_symbol(sharedps_hashcompatibility->s_thing, s); - else - pd_bang(sharedps_hashcompatibility->s_thing); -} - -void shared_usecompatibility(void) -{ - if (!sharedcompatibility_class) - sharedcompatibility_setup(0); -} - -void shared_setcompatibility(t_symbol *s) -{ - post("setting compatibility mode to '%s'", (s ? s->s_name : "none")); - if (sharedcompatibility_class) - { - if (sharedps_hashcompatibility->s_thing) - pd_symbol(sharedps_hashcompatibility->s_thing, s); - else - bug("shared_setcompatibility"); - } - else sharedcompatibility_setup(s); -} - -t_symbol *shared_getcompatibility(void) -{ - if (!sharedcompatibility_class) - sharedcompatibility_setup(0); - return (shared_compatibility); -} - -void shared_setmaxcompatibility(void) -{ - if (!sharedcompatibility_class) - sharedcompatibility_setup(0); - shared_setcompatibility(sharedps_max); -} - -int shared_getmaxcompatibility(void) -{ - if (!sharedcompatibility_class) - sharedcompatibility_setup(0); - return (shared_compatibility == sharedps_max); -} - int shared_matchignorecase(char *test, char *pattern) { char ct, cp; @@ -226,25 +148,6 @@ void loud_notimplemented(t_pd *x, char *name) loud_warning(x, 0, "not implemented (yet)"); } -void loud_incompatible(t_class *c, char *fmt, ...) -{ - if (shared_getmaxcompatibility()) - { - char buf[MAXPDSTRING]; - va_list ap; - va_start(ap, fmt); - vsprintf(buf, fmt, ap); - post("'%s' class incompatibility warning:\n\t%s", - class_getname(c), buf); - va_end(ap); - } -} - -void loud_incompatible_max(t_class *c, int maxmax, char *what) -{ - loud_incompatible(c, "more than %d %s requested", maxmax, what); -} - int loud_floatarg(t_class *c, int which, int ac, t_atom *av, t_float *vp, t_float minval, t_float maxval, int underaction, int overaction, char *what) @@ -283,8 +186,8 @@ int loud_floatarg(t_class *c, int which, int ac, t_atom *av, if (underaction & LOUD_CLIP) loud_warning(&c, 0, "%s rounded up to %g", what, minval); else - loud_incompatible(c, "less than %g %s requested", - minval, what); + loud_warning(&c, 0, "less than %g %s requested", + minval, what); } break; case LOUD_ARGOVER: @@ -293,8 +196,8 @@ int loud_floatarg(t_class *c, int which, int ac, t_atom *av, if (overaction & LOUD_CLIP) loud_warning(&c, 0, "%s truncated to %g", what, maxval); else - loud_incompatible(c, "more than %g %s requested", - maxval, what); + loud_warning(&c, 0, "more than %g %s requested", + maxval, what); } break; case LOUD_ARGTYPE: @@ -436,3 +339,70 @@ t_loudcontext *loudx_newcontext(t_pd *caller, char *callername, loudx_setcontext(lc, caller, callername, s, ac, av); return (lc); } + +void loudbug_post(char *fmt, ...) +{ + char buf[MAXPDSTRING]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, MAXPDSTRING-1, fmt, ap); + va_end(ap); + fprintf(stderr, "%s\n", buf); +} + +void loudbug_startpost(char *fmt, ...) +{ + char buf[MAXPDSTRING]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, MAXPDSTRING-1, fmt, ap); + va_end(ap); + fputs(buf, stderr); +} + +void loudbug_endpost(void) +{ + fputs("\n", stderr); +} + +void loudbug_postatom(int ac, t_atom *av) +{ + while (ac--) + { + char buf[MAXPDSTRING]; + atom_string(av++, buf, MAXPDSTRING); + fprintf(stderr, " %s", buf); + } +} + +void loudbug_postbinbuf(t_binbuf *bb) +{ + int ac = binbuf_getnatom(bb); + t_atom *aprev = 0, *ap = binbuf_getvec(bb); + while (ac--) + { + char buf[MAXPDSTRING]; + atom_string(ap, buf, MAXPDSTRING); + if (aprev) + { + if (aprev->a_type == A_SEMI) + fprintf(stderr, "\n%s", buf); + else + fprintf(stderr, " %s", buf); + } + else fprintf(stderr, "%s", buf); + aprev = ap++; + } + if (aprev) fputs("\n", stderr); +} + +void loudbug_bug(char *fmt, ...) +{ + char buf[MAXPDSTRING]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, MAXPDSTRING-1, fmt, ap); + va_end(ap); + fprintf(stderr, "miXed consistency check failed: %s\n", buf); + bug(buf); +} diff --git a/shared/common/loud.h b/shared/common/loud.h index 3fdcefd..64388c1 100644 --- a/shared/common/loud.h +++ b/shared/common/loud.h @@ -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. */ @@ -13,11 +13,6 @@ enum { LOUD_ARGOK, LOUD_ARGUNDER, LOUD_ARGOVER, LOUD_ARGTYPE, LOUD_ARGMISSING }; EXTERN_STRUCT _loudcontext; #define t_loudcontext struct _loudcontext -void shared_usecompatibility(void); -void shared_setcompatibility(t_symbol *s); -t_symbol *shared_getcompatibility(void); -void shared_setmaxcompatibility(void); -int shared_getmaxcompatibility(void); int shared_matchignorecase(char *test, char *pattern); char *loud_ordinal(int n); @@ -30,8 +25,6 @@ int loud_checkint(t_pd *x, t_float f, int *valuep, t_symbol *mess); void loud_classarg(t_class *c); void loud_warning(t_pd *x, char *who, char *fmt, ...); void loud_notimplemented(t_pd *x, char *name); -void loud_incompatible(t_class *c, char *fmt, ...); -void loud_incompatible_max(t_class *c, int maxmax, char *what); int loud_floatarg(t_class *c, int which, int ac, t_atom *av, t_float *vp, t_float minval, t_float maxval, int underaction, int overaction, char *what); @@ -50,4 +43,11 @@ void loudx_freecontext(t_loudcontext *lc); t_loudcontext *loudx_newcontext(t_pd *caller, char *callername, t_symbol *s, int ac, t_atom *av); +void loudbug_post(char *fmt, ...); +void loudbug_startpost(char *fmt, ...); +void loudbug_endpost(void); +void loudbug_postatom(int ac, t_atom *av); +void loudbug_postbinbuf(t_binbuf *bb); +void loudbug_bug(char *fmt, ...); + #endif diff --git a/shared/common/mifi.c b/shared/common/mifi.c index ac491f5..e3da3fe 100644 --- a/shared/common/mifi.c +++ b/shared/common/mifi.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004 krzYszcz and others. +/* Copyright (c) 2004-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. */ @@ -70,7 +70,10 @@ typedef unsigned char uchar; #endif #ifdef KRZYSZCZ -#define MIFI_DEBUG +# include "loud.h" +# define MIFI_DEBUG +#else +# define loudbug_bug(msg) fprintf(stderr, "BUG: %s\n", msg), bug(msg) #endif #define MIFI_VERBOSE @@ -89,8 +92,9 @@ typedef unsigned char uchar; #define MIFIUSER_DEFWHOLETICKS ((double)241920) /* whole note, 256*27*5*7 */ #define MIFIUSER_DEFTEMPO ((double)120960) /* 120 bpm in ticks/sec */ -#define MIFIEVENT_NALLOC 256 /* LATER do some research (average max?) */ -#define MIFIEVENT_INISIZE 2 /* always be able to handle channel events */ +#define MIFIEVENT_NALLOC 256 /* LATER do some research (average max?) */ +#define MIFIEVENT_INISIZE 2 /* always be able to handle channel events */ +#define MIFIEVENT_MAXSYSEX 256 /* FIXME */ typedef struct _mifievent { @@ -294,7 +298,7 @@ static int mifievent_settext(t_mifievent *ep, unsigned type, char *text) { if (type > 127) { - bug("mifievent_settext"); + loudbug_bug("mifievent_settext"); return (0); } if (mifievent_setlength(ep, strlen(text) + 1)) @@ -312,14 +316,17 @@ static int mifievent_settext(t_mifievent *ep, unsigned type, char *text) } #ifdef MIFI_DEBUG -static void mifievent_printsysex(t_mifievent *ep) +static void mifi_printsysex(int length, uchar *buf) { - int length = ep->e_length; - uchar *dp = ep->e_data; - startpost("sysex:"); + loudbug_startpost("sysex:"); while (length--) - postfloat((float)*dp++); - endpost(); + loudbug_startpost(" %d", (int)*buf++); + loudbug_endpost(); +} + +static void mifievent_printsysex(t_mifievent *ep) +{ + mifi_printsysex(ep->e_length, ep->e_data); } #endif @@ -349,12 +356,12 @@ static void mifievent_printmeta(t_mifievent *ep) else if (ep->e_meta == MIFIMETA_TEMPO) { int tempo = mifi_swap4(*(uint32 *)ep->e_data); - post("tempo (hard) %d after %d", tempo, ep->e_delay); + loudbug_post("tempo (hard) %d after %d", tempo, ep->e_delay); } else if (ep->e_meta == MIFIMETA_TIMESIG) { - post("meter %d/%d after %d", - ep->e_data[0], (1 << ep->e_data[1]), ep->e_delay); + loudbug_post("meter %d/%d after %d", + ep->e_data[0], (1 << ep->e_data[1]), ep->e_delay); } #endif } @@ -470,7 +477,7 @@ static void mifiread_updateticks(t_mifiread *mr) ((double)mr->mr_tempo); if (mr->mr_ticks.rt_tempo < MIFI_TICKEPSILON) { - bug("mifiread_updateticks"); + loudbug_bug("mifiread_updateticks"); mr->mr_ticks.rt_tempo = mr->mr_ticks.rt_deftempo; } } @@ -655,9 +662,21 @@ nextattempt: else if (status == MIFISYSEX_FIRST || status == MIFISYSEX_NEXT) { length = mifiread_getvarlen(mr); - /* FIXME optional read */ - if (mifiread_skipbytes(mr, length) < 0) - return (MIFIREAD_FATAL); + if (length > MIFIEVENT_MAXSYSEX) /* FIXME optional read */ + { + if (mifiread_skipbytes(mr, length) < 0) + return (MIFIREAD_FATAL); + } + else + { + uchar *tempbuf = getbytes(length); + if (mifiread_getbytes(mr, tempbuf, length) != length) + return (MIFIREAD_FATAL); +#ifdef MIFI_DEBUG + mifi_printsysex(length, tempbuf); +#endif + freebytes(tempbuf, length); + } goto nextattempt; } @@ -724,7 +743,7 @@ nextattempt: mifiread_updateticks(mr); #ifdef MIFI_DEBUG if (mr->mr_pass == 1) - post("barspan (hard) %g", mr->mr_ticks.rt_hardbar); + loudbug_post("barspan (hard) %g", mr->mr_ticks.rt_hardbar); #endif break; default: @@ -811,12 +830,13 @@ static int mifiread_doopen(t_mifiread *mr, const char *filename, mifiread_updateticks(mr); #ifdef MIFI_DEBUG if (mr->mr_nframes) - post("midi file (format %d): %d tracks, %d ticks (%d smpte frames)", - mr->mr_format, mr->mr_hdtracks, - mr->mr_ticks.rt_beatticks, mr->mr_nframes); + loudbug_post( + "midi file (format %d): %d tracks, %d ticks (%d smpte frames)", + mr->mr_format, mr->mr_hdtracks, + mr->mr_ticks.rt_beatticks, mr->mr_nframes); else - post("midi file (format %d): %d tracks, %d ticks per beat", - mr->mr_format, mr->mr_hdtracks, mr->mr_ticks.rt_beatticks); + loudbug_post("midi file (format %d): %d tracks, %d ticks per beat", + mr->mr_format, mr->mr_hdtracks, mr->mr_ticks.rt_beatticks); #endif return (1); badheader: @@ -850,8 +870,8 @@ static int mifiread_analyse(t_mifiread *mr, int complain) continue; if (mr->mr_newtrack) { -#ifdef MIFI_VERBOSE - post("track %d", mr->mr_ntracks); +#ifdef MIFI_DEBUG + loudbug_post("track %d", mr->mr_ntracks); #endif isnewtrack = 1; *tnamebuf = '\0'; @@ -876,13 +896,14 @@ static int mifiread_analyse(t_mifiread *mr, int complain) { *tnamep = gensym(tnamebuf); #ifdef MIFI_DEBUG - post("nonempty track name %s", (*tnamep)->s_name); + loudbug_post("nonempty track name %s", (*tnamep)->s_name); #endif } else *tnamep = &s_; } mr->mr_nevents++; } + /* FIXME sysex */ else if (evtype < 0x80) { mifievent_printmeta(ep); @@ -926,6 +947,9 @@ static int mifiread_analyse(t_mifiread *mr, int complain) *tnamep = gensym(tnamebuf); } } +#ifdef MIFI_VERBOSE + post("got %d midi tracks (out of %d)", mr->mr_ntracks, mr->mr_hdtracks); +#endif return (MIFIREAD_EOF); } else return (evtype); @@ -951,13 +975,13 @@ int mifiread_doit(t_mifiread *mr, t_mifireadhook hook, void *hookdata) mr->mr_trackndx = ntracks++; if (ntracks > mr->mr_ntracks) { - bug("mifiread_doit: too many tracks"); + loudbug_bug("mifiread_doit: too many tracks"); goto doitfail; } if (!mr->mr_tracknames[mr->mr_trackndx] || mr->mr_tracknames[mr->mr_trackndx] == &s_) { - bug("mifiread_doit: empty track name"); + loudbug_bug("mifiread_doit: empty track name"); mr->mr_tracknames[mr->mr_trackndx] = gensym("bug-track"); } } @@ -968,7 +992,8 @@ int mifiread_doit(t_mifiread *mr, t_mifireadhook hook, void *hookdata) { #ifdef MIFI_DEBUG if (evtype == MIFIREAD_EOF) - post("finished reading %d events from midi file", mr->mr_nevents); + loudbug_post("finished reading %d events from midi file", + mr->mr_nevents); #endif return (MIFIREAD_EOF); } @@ -1054,7 +1079,7 @@ t_symbol *mifiread_gettrackname(t_mifiread *mr) return (mr->mr_tracknames[mr->mr_trackndx]); else { - bug("mifiread_gettrackname"); + loudbug_bug("mifiread_gettrackname"); return (0); } } @@ -1062,30 +1087,30 @@ t_symbol *mifiread_gettrackname(t_mifiread *mr) unsigned mifiread_getstatus(t_mifiread *mr) { if (mr->mr_pass != 2) - bug("mifiread_getstatus"); + loudbug_bug("mifiread_getstatus"); return (mr->mr_event.e_status); } unsigned mifiread_getdata1(t_mifiread *mr) { if (mr->mr_pass != 2) - bug("mifiread_getdata1"); + loudbug_bug("mifiread_getdata1"); return (mr->mr_event.e_data[0]); } unsigned mifiread_getdata2(t_mifiread *mr) { if (mr->mr_pass != 2) - bug("mifiread_getdata2"); + loudbug_bug("mifiread_getdata2"); if (mr->mr_event.e_length < 2) - bug("mifiread_getdata2"); + loudbug_bug("mifiread_getdata2"); return (mr->mr_event.e_data[1]); } unsigned mifiread_getchannel(t_mifiread *mr) { if (mr->mr_pass != 2) - bug("mifiread_getchannel"); + loudbug_bug("mifiread_getchannel"); return (mr->mr_event.e_channel); } @@ -1155,7 +1180,7 @@ static void mifiwrite_updateticks(t_mifiwrite *mw) ((double)mw->mw_tempo); if (mw->mw_ticks.wt_tempo < MIFI_TICKEPSILON) { - bug("mifiwrite_updateticks"); + loudbug_bug("mifiwrite_updateticks"); mw->mw_ticks.wt_tempo = mw->mw_ticks.wt_deftempo; } mw->mw_ticks.wt_mscoef = @@ -1267,7 +1292,7 @@ int mifiwrite_open(t_mifiwrite *mw, const char *filename, char errmess[MAXPDSTRING], fnamebuf[MAXPDSTRING]; if (ntracks < 1 || ntracks > MIFI_MAXTRACKS) { - bug("mifiwrite_open 1"); + loudbug_bug("mifiwrite_open 1"); complain = 0; goto wopenfailed; } @@ -1277,7 +1302,7 @@ int mifiwrite_open(t_mifiwrite *mw, const char *filename, { if (mw->mw_ntracks != 1) { /* LATER consider replacing with a warning */ - bug("mifiwrite_open 2"); + loudbug_bug("mifiwrite_open 2"); complain = 0; goto wopenfailed; } @@ -1343,7 +1368,7 @@ static int mifiwrite_adjusttrack(t_mifiwrite *mw, uint32 eotdelay, int complain) skip = mw->mw_trackbytes + 4; length = mifi_swap4(mw->mw_trackbytes); #ifdef MIFI_DEBUG - post("adjusting track size to %d", mw->mw_trackbytes); + loudbug_post("adjusting track size to %d", mw->mw_trackbytes); #endif /* LATER add sanity check (compare to saved filepos) */ if (skip > 4 && @@ -1369,7 +1394,7 @@ int mifiwrite_opentrack(t_mifiwrite *mw, char *trackname, int complain) return (0); else if (mw->mw_trackndx++ == mw->mw_ntracks) { - bug("mifiwrite_opentrack"); + loudbug_bug("mifiwrite_opentrack"); return (0); } strncpy(th.th_type, "MTrk", 4); @@ -1410,7 +1435,7 @@ int mifiwrite_closetrack(t_mifiwrite *mw, double enddelay, int complain) } else { - bug("mifiwrite_closetrack"); + loudbug_bug("mifiwrite_closetrack"); return (0); } } @@ -1433,7 +1458,7 @@ int mifiwrite_channelevent(t_mifiwrite *mw, double delay, unsigned status, if (!MIFI_ISCHANNEL(status) || channel > 15 || data1 > 127 || (!shorter && data2 > 127)) { - bug("mifiwrite_channelevent"); + loudbug_bug("mifiwrite_channelevent"); return (0); } ep->e_delay = (uint32)(delay * mw->mw_ticks.wt_mscoef); diff --git a/shared/common/mifi.h b/shared/common/mifi.h index 1163a5d..e7948c7 100644 --- a/shared/common/mifi.h +++ b/shared/common/mifi.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004 krzYszcz and others. +/* Copyright (c) 2004-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. */ @@ -21,29 +21,42 @@ typedef int (*t_mifireadhook)(t_mifiread *mf, void *hookdata, int evtype); #define MIFIREAD_EOF -2 /* regular eof */ #define MIFIREAD_SKIP -1 /* error and successful skip to the next track */ -#define MIFIMETA_SEQNUM 0 -#define MIFIMETA_TEXT 1 -#define MIFIMETA_COPYRIGHT 2 -#define MIFIMETA_TRACKNAME 3 -#define MIFIMETA_INSTRUMENT 4 -#define MIFIMETA_LYRIC 5 -#define MIFIMETA_MARKER 6 -#define MIFIMETA_CUE 7 -#define MIFIMETA_MAXPRINTABLE 15 /* 1..15 are various text meta-events */ -#define MIFIMETA_CHANNEL 0x20 /* channel prefix */ -#define MIFIMETA_EOT 0x2f /* end of track */ -#define MIFIMETA_TEMPO 0x51 -#define MIFIMETA_SMPTE 0x54 /* SMPTE offset */ -#define MIFIMETA_TIMESIG 0x58 /* time signature */ -#define MIFIMETA_KEYSIG 0x59 /* key signature */ +#define MIFIMETA_SEQNUM 0 +#define MIFIMETA_TEXT 1 +#define MIFIMETA_COPYRIGHT 2 +#define MIFIMETA_TRACKNAME 3 +#define MIFIMETA_INSTRUMENT 4 +#define MIFIMETA_LYRIC 5 +#define MIFIMETA_MARKER 6 +#define MIFIMETA_CUE 7 +#define MIFIMETA_MAXPRINTABLE 15 /* 1..15 are various text meta-events */ +#define MIFIMETA_CHANNEL 0x20 /* channel prefix (obsolete) */ +#define MIFIMETA_PORT 0x21 /* port prefix (obsolete) */ +#define MIFIMETA_EOT 0x2f /* end of track */ +#define MIFIMETA_TEMPO 0x51 +#define MIFIMETA_SMPTE 0x54 /* SMPTE offset */ +#define MIFIMETA_TIMESIG 0x58 /* time signature */ +#define MIFIMETA_KEYSIG 0x59 /* key signature */ +#define MIFIMETA_PROPRIETARY 0x7f /* ...channel status codes go here, too obvious to #define... */ -#define MIFISYSEX_FIRST 0xf0 -#define MIFISYSEX_NEXT 0xf7 +#define MIFISYSEX_FIRST 0xf0 +#define MIFISYSEX_NEXT 0xf7 +#define MIFISYSEX_ESCAPE 0xf7 /* without preceding MIFISYSEX_FIRST */ /* this code is not returned as an event type, but in e_status of t_mifievent */ -#define MIFIEVENT_META 0xff +#define MIFIEVENT_META 0xff + +/* system messages (expected inside of sysex escape events) */ +#define MIFISYS_SONGPOINTER 0xf2 +#define MIFISYS_SONGSELECT 0xf3 +#define MIFISYS_TUNEREQUEST 0xf6 +#define MIFISYS_CLOCK 0xf8 +#define MIFISYS_START 0xfa +#define MIFISYS_CONTINUE 0xfb +#define MIFISYS_STOP 0xfc +#define MIFISYS_ACTIVESENSING 0xfe /* true if one of channel messages */ #define MIFI_ISCHANNEL(status) (((status) & 0x80) && (status) < 0xf0) diff --git a/shared/common/port.c b/shared/common/port.c index 5c14acb..159eab1 100644 --- a/shared/common/port.c +++ b/shared/common/port.c @@ -24,7 +24,7 @@ #include "common/loud.h" #include "common/grow.h" #include "common/binport.h" -#include "common/port.h" +#include "port.h" #ifdef KRZYSZCZ //#define PORT_DEBUG @@ -227,14 +227,14 @@ static t_symbol *port_getanysymbol(t_port *x, int ndx) static t_symbol *port_gettarget(t_port *x) { t_symbol *sel = port_getsymbol(x, 0); - if (sel == &s_) bug("port_gettarget"); + if (sel == &s_) loudbug_bug("port_gettarget"); return (sel); } static t_symbol *port_getselector(t_port *x) { t_symbol *sel = port_getanysymbol(x, 1); - if (sel == &s_) bug("port_getselector"); + if (sel == &s_) loudbug_bug("port_getselector"); return (sel); } @@ -511,7 +511,7 @@ static void import_addclassname(t_port *x, char *outname, t_atom *inatom) SETSYMBOL(&at, insym); else { - bug("import_addclassname"); + loudbug_bug("import_addclassname"); SETSYMBOL(&at, gensym("???")); } } @@ -588,9 +588,10 @@ static int imaction_N1_vtable(t_port *x, char *arg) flags = port_getint(x, 7); import_emstart(x, portps_vtable, port_getsymbol(x, 9), port_getint(x, 2)); #ifdef PORT_DEBUG - post("vtable \"%s\": size %d, range %d, coords %d %d %d %d, flags %d", - x->x_emname->s_name, x->x_emsize, - range, left, top, right, bottom, flags); + loudbug_post( + "vtable \"%s\": size %d, range %d, coords %d %d %d %d, flags %d", + x->x_emname->s_name, x->x_emsize, + range, left, top, right, bottom, flags); #endif import_emaddv(x, portps_vtable, "si;", gensym("size"), x->x_emsize); import_emaddv(x, portps_vtable, "siiii;", gensym("flags"), @@ -1168,7 +1169,7 @@ secondpass: goto secondpass; } } - else bug("port_doparse"); + else loudbug_bug("port_doparse"); return (PORT_UNKNOWN); } @@ -1182,7 +1183,7 @@ static int port_parsemessage(t_port *x) static void port_startparsing(t_port *x) { #ifdef PORT_DEBUG - post("parsing..."); + loudbug_post("parsing..."); #endif x->x_messcount = 0; x->x_illmess = 0; @@ -1213,7 +1214,7 @@ static void port_endparsing(t_port *x) x->x_pictfp = 0; } #ifdef PORT_DEBUG - post("end of parsing"); + loudbug_post("end of parsing"); #endif } @@ -1260,7 +1261,7 @@ static void bogus_tick(t_bogus *x) if (x->x_bound) { #ifdef PORT_DEBUG - post("bogus_tick: unbinding '%x'", (int)x); + loudbug_post("bogus_tick: unbinding '%x'", (int)x); #endif pd_unbind((t_pd *)x, portps_cleanup); x->x_bound = 0; @@ -1286,8 +1287,8 @@ static void bogus_cleanup(t_bogus *x) t_outlet **op; int i; #ifdef PORT_DEBUG - startpost("self-adjusting"); - binbuf_print(t->te_binbuf); + loudbug_startpost("self-adjusting "); + loudbug_postbinbuf(t->te_binbuf); #endif binbuf_add(bb, ac - 1, av + 1); binbuf_free(t->te_binbuf); @@ -1302,7 +1303,7 @@ static void bogus_cleanup(t_bogus *x) inlet_free(*ip); } #ifdef PORT_DEBUG - post("%d inlets deleted", BOGUS_NINLETS - i); + loudbug_post("%d inlets deleted", BOGUS_NINLETS - i); #endif for (i = 0, op = x->x_outlets + BOGUS_NOUTLETS - 1; i < BOGUS_NOUTLETS; i++, op--) @@ -1313,11 +1314,11 @@ static void bogus_cleanup(t_bogus *x) outlet_free(*op); } #ifdef PORT_DEBUG - post("%d outlets deleted", i); + loudbug_post("%d outlets deleted", i); #endif glist_retext(x->x_glist, t); } - else bug("bogus_cleanup"); + else loudbug_bug("bogus_cleanup"); x->x_glist = 0; clock_delay(x->x_clock, 0); } @@ -1348,7 +1349,7 @@ static void *bogus_new(t_symbol *s, int ac, t_atom *av) pd_bind((t_pd *)y, portps_cleanup); y->x_clock = clock_new(y, (t_method)bogushook_tick); #ifdef PORT_DEBUG - post("reclaiming %s", av->a_w.w_symbol->s_name); + loudbug_post("reclaiming %s", av->a_w.w_symbol->s_name); #endif return (z); } @@ -1380,8 +1381,8 @@ static void bogushook_cleanup(t_bogushook *x) t_atom *av = binbuf_getvec(t->te_binbuf); t_binbuf *bb = binbuf_new(); #ifdef PORT_DEBUG - startpost("hook-adjusting"); - binbuf_print(t->te_binbuf); + loudbug_startpost("hook-adjusting "); + loudbug_postbinbuf(t->te_binbuf); #endif ac--; av++; if (av->a_type == A_SYMBOL) @@ -1412,7 +1413,7 @@ static void bogushook_cleanup(t_bogushook *x) glist_retext(x->x_glist, t); } } - else bug("bogushook_cleanup"); + else loudbug_bug("bogushook_cleanup"); x->x_glist = 0; clock_delay(x->x_clock, 0); } @@ -1421,7 +1422,7 @@ static void bogushook_cleanup(t_bogushook *x) static void bogushook_free(t_bogushook *x) { #ifdef PORT_DEBUG - post("destroing the hook of '%s'", class_getname(*x->x_who)); + loudbug_post("destroing the hook of '%s'", class_getname(*x->x_who)); #endif pd_unbind((t_pd *)x, portps_cleanup); if (x->x_clock) clock_free(x->x_clock); diff --git a/shared/common/props.c b/shared/common/props.c index f5f2763..4dfe113 100644 --- a/shared/common/props.c +++ b/shared/common/props.c @@ -5,7 +5,7 @@ #include #include "m_pd.h" #include "common/grow.h" -#include "common/props.h" +#include "props.h" #ifdef KRZYSZCZ //#define PROPS_DEBUG diff --git a/shared/common/qtree.c b/shared/common/qtree.c index 368e38c..3d35769 100644 --- a/shared/common/qtree.c +++ b/shared/common/qtree.c @@ -3,6 +3,7 @@ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #include "m_pd.h" +#include "loud.h" #include "qtree.h" /* Since there is no sentinel node, the deletion routine has to have @@ -26,7 +27,7 @@ static int qnode_verify(t_qnode *np) { /* failure: two paths rooted in the same node contain different number of black nodes */ - bug("qnode_verify: not balanced"); + loudbug_bug("qnode_verify: not balanced"); return (0); } if (np->n_black) @@ -36,7 +37,7 @@ static int qnode_verify(t_qnode *np) if ((np->n_left && !np->n_left->n_black) || (np->n_right && !np->n_right->n_black)) { - bug("qnode_verify: adjacent red nodes"); + loudbug_bug("qnode_verify: adjacent red nodes"); return (0); } return (bhl); @@ -56,7 +57,7 @@ static int qnode_checkmulti(t_qnode *np1, t_qnode *np2) if (np1 && np2 && np1->n_key == np2->n_key) { if (np1 == np2) - bug("qnode_checkmulti"); + loudbug_bug("qnode_checkmulti"); else return (1); } @@ -66,27 +67,27 @@ static int qnode_checkmulti(t_qnode *np1, t_qnode *np2) static void qnode_post(t_qtree *tree, t_qnode *np, t_qnode_vshowhook hook, char *message) { - startpost("%g ", np->n_key); + loudbug_startpost("%g ", np->n_key); if (tree->t_valuetype == QTREETYPE_FLOAT) - startpost("%g ", QNODE_GETFLOAT(np)); + loudbug_startpost("%g ", QNODE_GETFLOAT(np)); else if (tree->t_valuetype == QTREETYPE_SYMBOL) - startpost("%s ", QNODE_GETSYMBOL(np)->s_name); + loudbug_startpost("%s ", QNODE_GETSYMBOL(np)->s_name); else if (tree->t_valuetype == QTREETYPE_ATOM) { t_atom *ap = QNODE_GETATOMPTR(np); if (ap->a_type == A_FLOAT) - startpost("%g ", ap->a_w.w_float); + loudbug_startpost("%g ", ap->a_w.w_float); else if (ap->a_type == A_SYMBOL) - startpost("%s ", ap->a_w.w_symbol->s_name); + loudbug_startpost("%s ", ap->a_w.w_symbol->s_name); } else if (hook) { char buf[MAXPDSTRING]; (*hook)(np, buf, MAXPDSTRING); - startpost("%s ", buf); + loudbug_startpost("%s ", buf); } - else startpost("0x%08x ", (int)QNODE_GETSYMBOL(np)); - startpost("%s ", (np->n_black ? "black" : "red")); + else loudbug_startpost("0x%08x ", (int)QNODE_GETSYMBOL(np)); + loudbug_startpost("%s ", (np->n_black ? "black" : "red")); if (qnode_checkmulti(np, np->n_parent) || qnode_checkmulti(np, np->n_left) || @@ -94,24 +95,24 @@ static void qnode_post(t_qtree *tree, t_qnode *np, qnode_checkmulti(np->n_parent, np->n_left) || qnode_checkmulti(np->n_parent, np->n_right) || qnode_checkmulti(np->n_left, np->n_right)) - startpost("multi "); + loudbug_startpost("multi "); if (np->n_parent) - startpost("(%g -> ", np->n_parent->n_key); + loudbug_startpost("(%g -> ", np->n_parent->n_key); else - startpost("(nul -> "); + loudbug_startpost("(nul -> "); if (np->n_left) - startpost("%g, ", np->n_left->n_key); + loudbug_startpost("%g, ", np->n_left->n_key); else - startpost("nul, "); + loudbug_startpost("nul, "); if (np->n_right) - startpost("%g)", np->n_right->n_key); + loudbug_startpost("%g)", np->n_right->n_key); else - startpost("nul)"); + loudbug_startpost("nul)"); if (message) - post(": %s", message); + loudbug_post(": %s", message); else - endpost(); + loudbug_endpost(); } /* Assert a standard stackless traversal producing the same sequence, @@ -136,12 +137,12 @@ static int qtree_checktraversal(t_qtree *tree) listwalk = listwalk->n_next; else { - bug("qtree_checktraversal 1"); + loudbug_bug("qtree_checktraversal 1"); qnode_post(tree, treewalk, 0, "treewalk"); if (listwalk) qnode_post(tree, listwalk, 0, "listwalk"); else - post("empty listwalk pointer"); + loudbug_post("empty listwalk pointer"); listwalk = treewalk; } treewalk = treewalk->n_right; @@ -159,12 +160,12 @@ static int qtree_checktraversal(t_qtree *tree) listwalk = listwalk->n_next; else { - bug("qtree_checktraversal 2"); + loudbug_bug("qtree_checktraversal 2"); qnode_post(tree, treewalk, 0, "treewalk"); if (listwalk) qnode_post(tree, listwalk, 0, "listwalk"); else - post("empty listwalk pointer"); + loudbug_post("empty listwalk pointer"); listwalk = treewalk; } treewalk = treewalk->n_right; @@ -188,7 +189,7 @@ void qtree_debug(t_qtree *tree, int level, t_qnode_vshowhook hook) { t_qnode *np; int count; - post("------------------------"); + loudbug_post("------------------------"); count = qtree_checktraversal(tree); if (level) { @@ -196,10 +197,10 @@ void qtree_debug(t_qtree *tree, int level, t_qnode_vshowhook hook) qnode_post(tree, np, hook, 0); if (level > 1) { - post("************"); + loudbug_post("************"); for (np = tree->t_last; np; np = np->n_prev) - startpost("%g ", np->n_key); - endpost(); + loudbug_startpost("%g ", np->n_key); + loudbug_endpost(); } } if (tree->t_root) @@ -209,15 +210,15 @@ void qtree_debug(t_qtree *tree, int level, t_qnode_vshowhook hook) first = first->n_left; while (last->n_right && last->n_right != tree->t_root) last = last->n_right; - post("count %d, height %d, root %g", - count, qnode_height(tree->t_root), tree->t_root->n_key); - post("first %g, root->left* %g, last %g, root->right* %g", - (tree->t_first ? tree->t_first->n_key : 0), first->n_key, - (tree->t_last ? tree->t_last->n_key : 0), last->n_key); + loudbug_post("count %d, height %d, root %g", + count, qnode_height(tree->t_root), tree->t_root->n_key); + loudbug_post("first %g, root->left* %g, last %g, root->right* %g", + (tree->t_first ? tree->t_first->n_key : 0), first->n_key, + (tree->t_last ? tree->t_last->n_key : 0), last->n_key); } - else post("empty"); - post("...verified (black-height is %d)", qtree_verify(tree)); - post("------------------------"); + else loudbug_post("empty"); + loudbug_post("...verified (black-height is %d)", qtree_verify(tree)); + loudbug_post("------------------------"); } #endif @@ -263,7 +264,7 @@ static t_qnode *qtree_preinserthook(t_qnode *np) if (np->n_right) { /* LATER revisit */ - bug("qtree_preinserthook"); + loudbug_bug("qtree_preinserthook"); return (0); /* do nothing */ } } @@ -280,7 +281,7 @@ static t_qnode *qtree_postinserthook(t_qnode *np) if (np->n_left) { /* LATER revisit */ - bug("qtree_postinserthook"); + loudbug_bug("qtree_postinserthook"); return (0); /* do nothing */ } } @@ -318,14 +319,14 @@ static t_qnode *qtree_doinsert(t_qtree *tree, double key, { if (parent->n_left && parent->n_right) { - bug("qtree_insert, callback return 1"); + loudbug_bug("qtree_insert, callback return 1"); parent = parent->n_next; } if (leftchild = (key < parent->n_key)) { if (parent->n_left) { - bug("qtree_insert, callback return 2"); + loudbug_bug("qtree_insert, callback return 2"); leftchild = 0; } } @@ -685,7 +686,7 @@ t_qnode *qtree_insertfloat(t_qtree *tree, double key, t_float f, t_atom *ap = &npa->na_value; SETFLOAT(ap, f); } - else bug("qtree_insertfloat"); + else loudbug_bug("qtree_insertfloat"); } return (np); } @@ -708,7 +709,7 @@ t_qnode *qtree_insertsymbol(t_qtree *tree, double key, t_symbol *s, t_atom *ap = &npa->na_value; SETSYMBOL(ap, s); } - else bug("qtree_insertsymbol"); + else loudbug_bug("qtree_insertsymbol"); } return (np); } @@ -725,7 +726,7 @@ t_qnode *qtree_insertatom(t_qtree *tree, double key, t_atom *ap, t_qnode_atom *npa = (t_qnode_atom *)np; npa->na_value = *ap; } - else bug("qtree_insertatom"); + else loudbug_bug("qtree_insertatom"); } return (np); } @@ -754,7 +755,7 @@ void qtree_inittyped(t_qtree *tree, t_qtreetype vtype, int freecount) nsize = sizeof(t_qnode_atom); break; default: - bug("qtree_inittyped"); + loudbug_bug("qtree_inittyped"); vtype = QTREETYPE_ILLEGAL; nsize = sizeof(t_qnode); } diff --git a/shared/common/rand.c b/shared/common/rand.c index 7a3fff4..4a54b3a 100644 --- a/shared/common/rand.c +++ b/shared/common/rand.c @@ -5,7 +5,7 @@ #include #include "m_pd.h" EXTERN double sys_getrealtime(void); /* used to be in m_imp.h */ -#include "common/rand.h" +#include "rand.h" /* borrowed from x_misc.c, LATER rethink */ void rand_seed(unsigned int *statep, unsigned int seed) diff --git a/shared/common/vefl.c b/shared/common/vefl.c index b7230d5..5510654 100644 --- a/shared/common/vefl.c +++ b/shared/common/vefl.c @@ -17,7 +17,7 @@ #include "shared.h" #include "unstable/fragile.h" #include "common/loud.h" -#include "common/vefl.h" +#include "vefl.h" #ifdef KRZYSZCZ //#define VEFL_DEBUG @@ -69,7 +69,7 @@ t_vefl *vefl_placement_new(t_vefl *vp, t_symbol *name, { if (sizeof(t_word) != sizeof(t_float)) { - bug("vefl_new: sizeof(t_word) != sizeof(t_float)"); + loudbug_bug("vefl_new: sizeof(t_word) != sizeof(t_float)"); return (0); } if (!vp) diff --git a/shared/getridof.baddeps b/shared/getridof.baddeps index 478cf4e..77c055a 100644 --- a/shared/getridof.baddeps +++ b/shared/getridof.baddeps @@ -5,6 +5,7 @@ unstable/fragile -> common/loud unstable/fringe -> unstable/forky common/props -> common/grow common/vefl -> common/loud, unstable/fragile +common/qtree -> common/loud common/binport -> common/lex common/port -> common/loud, common/grow, common/binport, unstable/forky, unstable/fragile, unstable/fringe diff --git a/shared/sickle/arsic.c b/shared/sickle/arsic.c index 8f0e309..fe9f595 100644 --- a/shared/sickle/arsic.c +++ b/shared/sickle/arsic.c @@ -8,6 +8,7 @@ #include #include "m_pd.h" #include "shared.h" +#include "common/loud.h" #include "common/vefl.h" #include "sickle/sic.h" #include "sickle/arsic.h" @@ -25,7 +26,7 @@ void arsic_redraw(t_arsic *x) t_garray *ap = (t_garray *)pd_findbyclass(x->s_mononame, garray_class); if (ap) garray_redraw(ap); - else if (x->s_vectors[0]) bug("arsic_redraw 1"); + else if (x->s_vectors[0]) loudbug_bug("arsic_redraw 1"); } else if (*x->s_stub) { @@ -35,7 +36,7 @@ void arsic_redraw(t_arsic *x) t_garray *ap = (t_garray *)pd_findbyclass(x->s_channames[ch], garray_class); if (ap) garray_redraw(ap); - else if (x->s_vectors[ch]) bug("arsic_redraw 2"); + else if (x->s_vectors[ch]) loudbug_bug("arsic_redraw 2"); } } } @@ -122,7 +123,7 @@ void arsic_dsp(t_arsic *x, t_signal **sp, t_perfroutine perf, int complain) for (i = 0; i < nsigs; i++) *ap++ = (t_int)sp[i]->s_vec; dsp_addv(perf, x->s_nperfargs, x->s_perfargs); } - else bug("arsic_dsp"); + else loudbug_bug("arsic_dsp"); } void arsic_free(t_arsic *x) diff --git a/shared/sickle/sic.c b/shared/sickle/sic.c index 4557c4b..3630b2b 100644 --- a/shared/sickle/sic.c +++ b/shared/sickle/sic.c @@ -60,9 +60,8 @@ t_float *sic_makecostable(int *sizep) if (sz >= *sizep) break; #ifdef SIC_DEBUG - fprintf(stderr, - "request for a costable of %d points (effective %d, ndx %d)\n", - *sizep, sz, ndx); + loudbug_post("request for a costable of %d points (effective %d, ndx %d)", + *sizep, sz, ndx); #endif *sizep = sz; if (sic_costables[ndx]) @@ -77,7 +76,7 @@ t_float *sic_makecostable(int *sizep) if (table) { #ifdef SIC_DEBUG - fprintf(stderr, "got %d points of a costable\n", cnt); + loudbug_post("got %d points of a costable", cnt); #endif while (cnt--) { @@ -105,7 +104,7 @@ void sic_setup(t_class *c, void *dspfn, void *floatfn) t_shared_wrappy wrappy; wrappy.w_d = SHARED_UNITBIT32 + 0.5; if ((unsigned)wrappy.w_i[SHARED_LOWOFFSET] != 0x80000000) - bug("sic_setup: unexpected machine alignment"); + loudbug_bug("sic_setup: unexpected machine alignment"); checked = 1; } if (floatfn != SIC_NOMAINSIGNALIN) diff --git a/shared/toxy/plusbob.c b/shared/toxy/plusbob.c index 4ea96e2..9dae191 100644 --- a/shared/toxy/plusbob.c +++ b/shared/toxy/plusbob.c @@ -88,12 +88,12 @@ static void plusbob_doattach(t_plusbob *bob, t_plusbob *parent) if (bob->bob_next = parent->bob_children) { if (parent->bob_children->bob_prev) - bug("plusbob_doattach 1"); + loudbug_bug("plusbob_doattach 1"); parent->bob_children->bob_prev = bob; } parent->bob_children = bob; } - else bug("plusbob_doattach 2"); + else loudbug_bug("plusbob_doattach 2"); } static void plusbob_dodetach(t_plusbob *bob) @@ -103,7 +103,7 @@ static void plusbob_dodetach(t_plusbob *bob) if (bob->bob_prev) { if (bob == bob->bob_parent->bob_children) - bug("plusbob_dodetach 1"); + loudbug_bug("plusbob_dodetach 1"); bob->bob_prev->bob_next = bob->bob_next; } if (bob->bob_next) @@ -111,7 +111,7 @@ static void plusbob_dodetach(t_plusbob *bob) if (bob == bob->bob_parent->bob_children) bob->bob_parent->bob_children = bob->bob_next; } - else bug("plusbob_dodetach 2"); + else loudbug_bug("plusbob_dodetach 2"); } /* To be called from derived constructors. @@ -179,7 +179,7 @@ void plusbob_release(t_plusbob *bob) if (bob->bob_refcount == 0) plusbob_free(bob); else - bug("plusbob_release"); + loudbug_bug("plusbob_release"); } } } @@ -203,9 +203,9 @@ void plusbob_attach(t_plusbob *bob, t_plusbob *newparent) if (tp->tp_attachfn) (*tp->tp_attachfn)(bob); } else if (newparent) - bug("plusbob_attach 1"); + loudbug_bug("plusbob_attach 1"); else - bug("plusbob_attach 2"); + loudbug_bug("plusbob_attach 2"); } t_plusbob *plusbob_getnext(t_plusbob *bob) @@ -272,7 +272,7 @@ int plustag_validtype(t_symbol *tag, t_symbol *tname, t_pd *caller) } } else if (plustag_isvalid(tag, caller)) /* print the error there */ - bug("plustag_validtype"); + loudbug_bug("plustag_validtype"); return (0); } @@ -294,7 +294,7 @@ int plustag_validroot(t_symbol *tag, t_symbol *rname, t_pd *caller) } } else if (plustag_isvalid(tag, caller)) /* print the error there */ - bug("plustag_validroot"); + loudbug_bug("plustag_validroot"); return (0); } @@ -303,7 +303,7 @@ t_symbol *plustag_typename(t_symbol *tag, int validate, t_pd *caller) if (!validate || tag->s_name == plustag_name) return (((t_plusbob *)tag)->bob_type->tp_name); else if (plustag_isvalid(tag, caller)) /* print the error there */ - bug("plustag_typename"); + loudbug_bug("plustag_typename"); return (0); } @@ -312,7 +312,7 @@ t_symbol *plustag_rootname(t_symbol *tag, int validate, t_pd *caller) if (!validate || tag->s_name == plustag_name) return (((t_plusbob *)tag)->bob_root->tp_name); else if (plustag_isvalid(tag, caller)) /* print the error there */ - bug("plustag_rootname"); + loudbug_bug("plustag_rootname"); return (0); } diff --git a/shared/toxy/scriptlet.c b/shared/toxy/scriptlet.c index cd12f06..348d2c7 100644 --- a/shared/toxy/scriptlet.c +++ b/shared/toxy/scriptlet.c @@ -71,7 +71,7 @@ static t_canvas *scriptlet_canvasvalidate(t_scriptlet *sp, int visedonly) cv = sp->s_cv = sp->s_cvfn(sp->s_owner); else { - bug("scriptlet_canvasvalidate"); + loudbug_bug("scriptlet_canvasvalidate"); return (0); } if (cv && (!visedonly || glist_isvisible(cv))) @@ -429,7 +429,7 @@ void scriptlet_prealloc(t_scriptlet *sp, int sz, int mayshrink) if (sp->s_buffer != sp->s_bufini) freebytes(sp->s_buffer, sp->s_size * sizeof(*sp->s_buffer)); else - bug("scriptlet_prealloc"); + loudbug_bug("scriptlet_prealloc"); sp->s_size = SCRIPTLET_INISIZE; sp->s_buffer = sp->s_bufini; } @@ -700,7 +700,7 @@ static int verslet_parse(t_verslet *vp, char *buf, int multiline) { vp->v_package[plen] = 0; #ifdef SCRIPTLET_DEBUG - fprintf(stderr, "package \"%s\"\n", vp->v_package); + loudbug_post("package \"%s\"", vp->v_package); #endif while (*ptr == ' ' || *ptr == '\t') ptr++; if (*ptr >= '0' && *ptr <= '9') @@ -718,8 +718,7 @@ static int verslet_parse(t_verslet *vp, char *buf, int multiline) { vp->v_version[vlen] = 0; #ifdef SCRIPTLET_DEBUG - fprintf(stderr, "version \"%s\"\n", - vp->v_version); + loudbug_post("version \"%s\"", vp->v_version); #endif return (1); } @@ -921,7 +920,7 @@ int scriptlet_rcload(t_scriptlet *sp, t_pd *caller, char *rc, char *ext, vp = verslet_new(sp->s_owner); if (!verslet_parse(vp, builtin, 1)) { - bug("scriptlet_rcload 1"); + loudbug_bug("scriptlet_rcload 1"); verslet_free(vp); vp = 0; } @@ -934,7 +933,7 @@ int scriptlet_rcload(t_scriptlet *sp, t_pd *caller, char *rc, char *ext, } else { - bug("scriptlet_rcload 2"); + loudbug_bug("scriptlet_rcload 2"); result = SCRIPTLET_NOFILE; } } diff --git a/test/cyclone/cyclone-test.pd b/test/cyclone/cyclone-test.pd index c8d6333..f60a320 100644 --- a/test/cyclone/cyclone-test.pd +++ b/test/cyclone/cyclone-test.pd @@ -1,40 +1,44 @@ -#N canvas 150 47 650 442 12; -#X obj 39 399 cyclone; -#X msg 39 19 bang; -#X msg 244 19 import; -#X obj 43 220 forward texthelp; -#X obj 63 282 r texthelp; -#X msg 52 252 send binhelp; -#X msg 178 252 send texthelp; -#X obj 90 309 r binhelp; -#X obj 90 338 sprintf import ../../../ref/c74help/bin/%s.help; -#X obj 63 369 sprintf import ../../../ref/c74help/text/%s.help; -#X msg 92 19 dummies; -#X msg 170 19 reps; -#X msg 125 181 buffir~; -#X obj 244 56 cyclone; -#X msg 43 177 record~; -#X obj 39 94 cyclone ../../../ref; -#X msg 211 181 fffb~; -#X msg 286 181 pictctrl; -#X msg 43 148 universal; -#X msg 140 148 funbuff; -#X obj 244 94 cyclone ../../../rob; -#X msg 222 148 prob; -#X connect 1 0 15 0; -#X connect 2 0 13 0; +#N canvas 150 47 650 459 12; +#X obj 37 419 cyclone; +#X msg 37 58 bang; +#X msg 66 24 import; +#X obj 41 240 forward texthelp; +#X obj 61 302 r texthelp; +#X msg 50 272 send binhelp; +#X msg 176 272 send texthelp; +#X obj 88 329 r binhelp; +#X obj 88 358 sprintf import ../../../ref/c74help/bin/%s.help; +#X obj 61 389 sprintf import ../../../ref/c74help/text/%s.help; +#X msg 123 201 buffir~; +#X msg 41 197 record~; +#X msg 209 201 fffb~; +#X msg 284 201 pictctrl; +#X msg 41 168 universal; +#X msg 138 168 funbuff; +#X msg 220 168 prob; +#X obj 137 24 loadbang; +#X obj 137 126 cyclone; +#X msg 177 91 cd ../../../rob; +#X msg 137 53 cd ../../../../ref; +#X msg 213 126 pwd; +#X obj 72 126 print; +#X connect 1 0 18 0; +#X connect 2 0 18 0; #X connect 4 0 9 0; #X connect 5 0 3 0; #X connect 6 0 3 0; #X connect 7 0 8 0; #X connect 8 0 0 0; #X connect 9 0 0 0; -#X connect 10 0 15 0; -#X connect 11 0 15 0; +#X connect 10 0 3 0; +#X connect 11 0 3 0; #X connect 12 0 3 0; +#X connect 13 0 3 0; #X connect 14 0 3 0; +#X connect 15 0 3 0; #X connect 16 0 3 0; -#X connect 17 0 3 0; -#X connect 18 0 3 0; -#X connect 19 0 3 0; -#X connect 21 0 3 0; +#X connect 17 0 20 0; +#X connect 18 0 22 0; +#X connect 19 0 18 0; +#X connect 20 0 18 0; +#X connect 21 0 18 0; diff --git a/test/cyclone/maxmode-test.pd b/test/cyclone/maxmode-test.pd index 1a4512a..75271e8 100644 --- a/test/cyclone/maxmode-test.pd +++ b/test/cyclone/maxmode-test.pd @@ -1,20 +1,36 @@ -#N canvas 356 180 524 263 12; +#N canvas 356 180 524 287 12; #X obj 310 29 r #compatibility; #X obj 23 66 s #compatibility; #X msg 23 29 bang; -#X msg 78 29 symbol max; -#X obj 24 173 prepend test; -#X msg 79 130 set this; -#X msg 184 130 set that; -#X msg 24 130 x; +#X obj 25 193 prepend test; +#X msg 136 122 set this; +#X msg 137 159 set that; +#X msg 25 122 x; #X obj 310 66 print mode; -#X obj 24 208 print output; -#X msg 178 29 symbol barry; -#X connect 0 0 8 0; +#X msg 78 29 set max; +#X msg 165 29 set barry; +#X msg 77 122 bang; +#X obj 25 228 print pp; +#X msg 366 122 set this; +#X msg 367 159 set that; +#X msg 255 122 x; +#X msg 307 122 bang; +#X obj 255 228 print aa; +#X obj 255 193 Append test; +#X msg 155 193 bang; +#X obj 155 228 maxmode; +#X connect 0 0 7 0; #X connect 2 0 1 0; -#X connect 3 0 1 0; -#X connect 4 0 9 0; -#X connect 5 0 4 0; -#X connect 6 0 4 0; -#X connect 7 0 4 0; -#X connect 10 0 1 0; +#X connect 3 0 11 0; +#X connect 4 0 3 0; +#X connect 5 0 3 0; +#X connect 6 0 3 0; +#X connect 8 0 1 0; +#X connect 9 0 1 0; +#X connect 10 0 3 0; +#X connect 12 0 17 0; +#X connect 13 0 17 0; +#X connect 14 0 17 0; +#X connect 15 0 17 0; +#X connect 17 0 16 0; +#X connect 18 0 19 0; diff --git a/toxy/plustot.c b/toxy/plustot.c index 3e6ec7c..1a738ef 100644 --- a/toxy/plustot.c +++ b/toxy/plustot.c @@ -99,8 +99,8 @@ t_plustin *plustin_create(t_plustype *tp, t_plusbob *parent, t_symbol *id) if (interp && (tin = (t_plustin *)plusenv_create(tp, parent, id))) { #ifdef PLUSTOT_DEBUG - fprintf(stderr, "plustin_create '%s' over %x\n", - (id ? id->s_name : "default"), (int)interp); + loudbug_post("plustin_create '%s' over %x", + (id ? id->s_name : "default"), (int)interp); #endif tin->tin_interp = interp; Tcl_Preserve(interp); @@ -118,8 +118,8 @@ static void plustin_delete(t_plustin *tin) { #ifdef PLUSTOT_DEBUG t_symbol *id = plusenv_getid((t_plusenv *)tin); - fprintf(stderr, "plustin_delete '%s' over %x\n", - (id ? id->s_name : "default"), (int)tin->tin_interp); + loudbug_post("plustin_delete '%s' over %x", + (id ? id->s_name : "default"), (int)tin->tin_interp); #endif Tcl_Preserve(tin->tin_interp); if (!Tcl_InterpDeleted(tin->tin_interp)) @@ -290,7 +290,7 @@ static void plustob_attach(t_plustob *tob) tob->tob_tin = tin; plusbob_preserve((t_plusbob *)tin); } - else bug("plustob_attach"); + else loudbug_bug("plustob_attach"); } /* To be called from client code. @@ -459,8 +459,7 @@ Tcl_Obj *plustob_setlist(t_plustob *tob, int ac, t_atom *av) if (count > tob->tob_elbufsize) { #ifdef PLUSTOT_DEBUG - fprintf(stderr, "growing +To %d -> %d\n", - tob->tob_elbufsize, count); + loudbug_post("growing +To %d -> %d", tob->tob_elbufsize, count); #endif tob->tob_elbuf = grow_nodata(&count, &tob->tob_elbufsize, tob->tob_elbuf, @@ -576,8 +575,7 @@ Tcl_Obj *plustob_setbinbuf(t_plustob *tob, t_binbuf *bb) { int n = count; #ifdef PLUSTOT_DEBUG - fprintf(stderr, "growing +To %d -> %d\n", - tob->tob_elbufsize, count); + loudbug_post("growing +To %d -> %d", tob->tob_elbufsize, count); #endif tob->tob_elbuf = grow_nodata(&n, &tob->tob_elbufsize, tob->tob_elbuf, @@ -694,7 +692,7 @@ t_plusvar *plusvar_create(t_plustype *tp, t_plustin *tin, Tcl_Obj *ob, } else { - bug("plusvar_create"); + loudbug_bug("plusvar_create"); goto varfailed2; } if (index) @@ -779,11 +777,12 @@ static Tcl_Obj *plusvar_postset(t_plusvar *var) { #ifdef PLUSTOT_DEBUGREFCOUNTS if (var->var_index) - fprintf(stderr, "vv %x plusvar_postset [%s(%s)]\n", - (int)tob->tob_value, var->var_name, var->var_index); + loudbug_post("vv %x plusvar_postset [%s(%s)]", + (int)tob->tob_value, var->var_name, + var->var_index); else - fprintf(stderr, "vv %x plusvar_postset [%s]\n", - (int)tob->tob_value, var->var_name); + loudbug_post("vv %x plusvar_postset [%s]", + (int)tob->tob_value, var->var_name); #endif } else plusloud_tclerror(0, interp, "cannot set variable"); @@ -932,7 +931,7 @@ void plusstring_release(t_plusstring *ps) if (ps->ps_buf) freebytes(ps->ps_buf, ps->ps_len); freebytes(ps, sizeof(*ps)); } - else bug("plusstring_release"); + else loudbug_bug("plusstring_release"); } } @@ -1012,8 +1011,8 @@ static t_plusproxy *plusproxy_new(t_pd *master, int ndx, t_plustin *tin) static void plusproxy_free(t_plusproxy *pp) { #ifdef PLUSTOT_DEBUG - fprintf(stderr, "plusproxy_free (%s %d)\n", - (pp->pp_var ? pp->pp_var->var_name : "empty"), pp->pp_ndx); + loudbug_post("plusproxy_free (%s %d)", + (pp->pp_var ? pp->pp_var->var_name : "empty"), pp->pp_ndx); #endif if (pp->pp_var) plusbob_release((t_plusbob *)pp->pp_var); @@ -1066,11 +1065,11 @@ static void plusproxy_debug(t_plusproxy *pp) t_plustin *tin = ((t_plustob *)pp->pp_var)->tob_tin; t_symbol *id = plusenv_getid((t_plusenv *)tin); t_symbol *glname = plustin_getglistname(tin); - fprintf(stderr, "+proxy %d, glist %x\n", - pp->pp_ndx, (int)((t_plustot *)pp->pp_master)->x_glist); - fprintf(stderr, " plustin '%s' (%s) over %x\n", - (id ? id->s_name : "default"), - (glname ? glname->s_name : ""), (int)tin->tin_interp); + loudbug_post("+proxy %d, glist %x", + pp->pp_ndx, (int)((t_plustot *)pp->pp_master)->x_glist); + loudbug_post(" plustin '%s' (%s) over %x", (id ? id->s_name : "default"), + (glname ? glname->s_name : ""), + (int)tin->tin_interp); } #endif @@ -1094,7 +1093,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit) } else buf[size] = 0; strncpy(buf, tp->start, size); - fprintf(stderr, "%s ", buf); + loudbug_startpost("%s ", buf); } #endif tp++; @@ -1160,7 +1159,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit) if (!doit) { #ifdef PLUSTOT_DEBUG - fprintf(stderr, "(inlet %d) ", inno); + loudbug_startpost("(inlet %d) ", inno); #endif if (inno >= x->x_nproxies) x->x_nproxies = inno + 1; @@ -1181,7 +1180,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit) else { PLUSDEBUG_ENDPOST("plustot_usevariable"); - bug("plustot_usevariable"); + loudbug_bug("plustot_usevariable"); goto badvariable; } } @@ -1257,7 +1256,7 @@ static int plustot_doparsevariables(t_plustot *x, Tcl_Interp *interp, int sz = (tp->size < MAXPDSTRING ? tp->size : MAXPDSTRING); strncpy(buf, tp->start, sz); buf[sz] = 0; - fprintf(stderr, "simple word's text: %s\n", buf); + loudbug_post("simple word's text: %s", buf); } #endif if (ntok-- && tp->type == TCL_TOKEN_TEXT && tp->size > 0) @@ -1289,7 +1288,7 @@ static int plustot_doparsevariables(t_plustot *x, Tcl_Interp *interp, int sz = (tp->size < MAXPDSTRING ? tp->size : MAXPDSTRING); strncpy(buf, tp->start, sz); buf[sz] = 0; - fprintf(stderr, "other type (%d): %s\n", tp->type, buf); + loudbug_post("other type (%d): %s", tp->type, buf); } #endif tp++; @@ -1307,7 +1306,7 @@ static int plustot_parsevariables(t_plustot *x, Tcl_Interp *interp, { int nvars; #ifdef PLUSTOT_DEBUG - if (!doit) fprintf(stderr, "variables: "); + if (!doit) loudbug_startpost("variables: "); #endif nvars = plustot_doparsevariables(x, interp, buf, len, parsep, doit); #ifdef PLUSTOT_DEBUG @@ -1315,10 +1314,10 @@ static int plustot_parsevariables(t_plustot *x, Tcl_Interp *interp, { if (nvars > 0) { - fprintf(stderr, "\n%d variable substitutions\n", nvars); - fprintf(stderr, "%d inlets requested\n", x->x_nproxies); + loudbug_post("\n%d variable substitutions", nvars); + loudbug_post("%d inlets requested", x->x_nproxies); } - else if (nvars == 0) fprintf(stderr, "none\n"); + else if (nvars == 0) loudbug_post("none"); } #endif return (nvars); @@ -1355,7 +1354,7 @@ static int plustot_makeproxies(t_plustot *x) } else { - bug("plustot_makeproxies"); + loudbug_bug("plustot_makeproxies"); goto proxiesfailed; } return (1); @@ -1396,7 +1395,7 @@ static int plustot_resetwords(t_plustot *x) { int n = nwords; #ifdef PLUSTOT_DEBUG - fprintf(stderr, "growing words %d -> %d\n", x->x_maxwords, nwords); + loudbug_post("growing words %d -> %d", x->x_maxwords, nwords); #endif x->x_words = grow_nodata(&n, &x->x_maxwords, x->x_words, PLUSTOT_INIMAXWORDS, x->x_wordsini, @@ -1423,7 +1422,7 @@ static int plustot_resetargs(t_plustot *x) { int n = nargs; #ifdef PLUSTOT_DEBUG - fprintf(stderr, "growing argv %d -> %d\n", x->x_maxargs, nargs); + loudbug_post("growing argv %d -> %d", x->x_maxargs, nargs); #endif x->x_argv = grow_nodata(&n, &x->x_maxargs, x->x_argv, PLUSTOT_INIMAXWORDS, x->x_argvini, @@ -1438,7 +1437,7 @@ static int plustot_resetargs(t_plustot *x) } else if (nargs < x->x_maxargs) { - bug("plustot_resetargs"); /* LATER rethink */ + loudbug_bug("plustot_resetargs"); /* LATER rethink */ plustot_initwords(x); plustot_initargs(x); return (0); @@ -1457,17 +1456,16 @@ static int plustot_makewords(t_plustot *x) int len; char buf[TCL_UTF_MAX]; #ifdef PLUSTOT_DEBUG - fprintf(stderr, "arguments:\n"); + loudbug_post("arguments:"); #endif for (i = 1, tp = x->x_tailparse.tokenPtr; i < nwords; i++, tp += ncomponents) { #ifdef PLUSTOT_DEBUG - fprintf(stderr, - " %s token: type %d[%d], having %d[%d] component%s\n", - loud_ordinal(i), tp->type, tp[1].type, - tp->numComponents, tp[1].numComponents, - (tp->numComponents > 1 ? "s" : "")); + loudbug_post(" %s token: type %d[%d], having %d[%d] component%s", + loud_ordinal(i), tp->type, tp[1].type, + tp->numComponents, tp[1].numComponents, + (tp->numComponents > 1 ? "s" : "")); #endif ncomponents = tp->numComponents; tp++; @@ -1605,16 +1603,17 @@ static int plustot_argsfromtokens(t_plustot *x, Tcl_Interp *interp) int i, nwords = x->x_tailparse.numWords + 1; Tcl_Token *tp; #ifdef PLUSTOT_DEBUG - fprintf(stderr, "arguments:\n"); + loudbug_post("arguments:"); #endif for (i = 1, tp = x->x_tailparse.tokenPtr; i < nwords; i++, tp += (tp->numComponents + 1)) { int result; #ifdef PLUSTOT_DEBUG - fprintf(stderr, " %s token: type %d[%d], having %d component%s", - loud_ordinal(i), tp->type, tp[1].type, - tp->numComponents, (tp->numComponents > 1 ? "s" : "")); + loudbug_startpost(" %s token: type %d[%d], having %d component%s", + loud_ordinal(i), tp->type, tp[1].type, + tp->numComponents, + (tp->numComponents > 1 ? "s" : "")); #endif result = Tcl_EvalTokensStandard(interp, tp + 1, tp->numComponents); if (result == TCL_OK) @@ -1625,9 +1624,9 @@ static int plustot_argsfromtokens(t_plustot *x, Tcl_Interp *interp) "plustot_argsfromwords"); Tcl_ResetResult(interp); #ifdef PLUSTOT_DEBUG - fprintf(stderr, ", %sshared: '%s'\n", - (Tcl_IsShared(x->x_argv[i]) ? "" : "not "), - Tcl_GetString(x->x_argv[i])); + loudbug_post(", %sshared: '%s'", + (Tcl_IsShared(x->x_argv[i]) ? "" : "not "), + Tcl_GetString(x->x_argv[i])); #endif } else @@ -1787,10 +1786,10 @@ static void plustot_debug(t_plustot *x) t_plustin *tin = x->x_tob->tob_tin; t_symbol *id = plusenv_getid((t_plusenv *)tin); t_symbol *glname = plustin_getglistname(tin); - fprintf(stderr, "+tot, glist %x\n", (int)x->x_glist); - fprintf(stderr, " plustin '%s' (%s) over %x\n", - (id ? id->s_name : "default"), - (glname ? glname->s_name : ""), (int)tin->tin_interp); + loudbug_post("+tot, glist %x", (int)x->x_glist); + loudbug_post(" plustin '%s' (%s) over %x", (id ? id->s_name : "default"), + (glname ? glname->s_name : ""), + (int)tin->tin_interp); if (x->x_mainproxy) plusproxy_debug(x->x_mainproxy); } diff --git a/toxy/plustot.qlist.c b/toxy/plustot.qlist.c index e077177..e4787fd 100644 --- a/toxy/plustot.qlist.c +++ b/toxy/plustot.qlist.c @@ -56,8 +56,9 @@ static t_binbuf *plustot_qlist_usurp(t_plustot_qlist *x) { t_binbuf *bb = ((t_qlist *)booty)->x_binbuf; #ifdef PLUSTOT_QLIST_DEBUG - post("booty '%s' at %x:", class_getname(*(t_pd *)booty), (int)booty); - binbuf_print(bb); + loudbug_post("booty '%s' at %x:", + class_getname(*(t_pd *)booty), (int)booty); + loudbug_postbinbuf(bb); #endif return (bb); } diff --git a/toxy/tot.c b/toxy/tot.c index 9e1c07d..65bfe9a 100644 --- a/toxy/tot.c +++ b/toxy/tot.c @@ -108,7 +108,7 @@ static t_symbol *tot_getcvname(t_tot *x) return (x->x_dotname); else { - bug("tot_getcvname"); + loudbug_bug("tot_getcvname"); return (gensym("???")); } } @@ -289,8 +289,8 @@ static void tot__vised(t_tot *x, t_symbol *s, t_floatarg f) int flag = f != 0.; #ifdef TOT_DEBUG t_symbol *pn = tot_getpathname(x, 0); - post("tot__vised %s %g (pathname %s) ", s->s_name, f, - (pn ? pn->s_name : "unknown")); + loudbug_post("tot__vised %s %g (pathname %s) ", s->s_name, f, + (pn ? pn->s_name : "unknown")); #endif if (!x->x_visedpathname) { @@ -310,13 +310,14 @@ static void tot_debug(t_tot *x) t_symbol *pn = tot_getpathname(x, 0); int sz; char *bp; - post("containing glist: %x", x->x_glist); - post("destination: %s", tot_getcvname(x)->s_name); - post("pathname%s %s", (pn ? ":" : ""), (pn ? pn->s_name : "unknown")); + loudbug_post("containing glist: %x", x->x_glist); + loudbug_post("destination: %s", tot_getcvname(x)->s_name); + loudbug_post("pathname%s %s", (pn ? ":" : ""), + (pn ? pn->s_name : "unknown")); bp = scriptlet_getbuffer(x->x_transient, &sz); - post("transient buffer (size %d):\n\"%s\"", sz, bp); + loudbug_post("transient buffer (size %d):\n\"%s\"", sz, bp); bp = scriptlet_getbuffer(x->x_persistent, &sz); - post("persistent buffer (size %d):\n\"%s\"", sz, bp); + loudbug_post("persistent buffer (size %d):\n\"%s\"", sz, bp); } #endif @@ -394,7 +395,7 @@ static void tot_attach(t_tot *x) x->x_guidetached = 0; } } - else bug("tot_attach"); + else loudbug_bug("tot_attach"); } } @@ -461,7 +462,7 @@ static void totspy_anything(t_totspy *ts, t_symbol *s, int ac, t_atom *av) ts->ts_lastmotion[2] = av[2]; ts->ts_gotmotion = 1; } - else bug("totspy_anything"); + else loudbug_bug("totspy_anything"); } if (ts->ts_on) { diff --git a/toxy/widget.c b/toxy/widget.c index b0b83ac..6700812 100644 --- a/toxy/widget.c +++ b/toxy/widget.c @@ -21,7 +21,7 @@ static t_class *makeshift_class; #ifdef KRZYSZCZ -//#define WIDGET_DEBUG +#define WIDGET_DEBUG //#define TOW_DEBUG //#define WIDGET_PROFILE #endif @@ -159,10 +159,10 @@ static void widgetprofile_handler_quit(void) static void widget_profile(t_widget *x) { - fputs("total time in ms:\n", stderr); - fprintf(stderr, "handler get %g\n", widgetprofile_handlerslice[0] * 1000.); - fprintf(stderr, "handler eval %g\n", widgetprofile_handlerslice[1] * 1000.); - fprintf(stderr, "handler push %g\n", widgetprofile_handlerslice[2] * 1000.); + loudbug_post("total time in ms:"); + loudbug_post("\thandler get %g", widgetprofile_handlerslice[0] * 1000.); + loudbug_post("\thandler eval %g", widgetprofile_handlerslice[1] * 1000.); + loudbug_post("\thandler push %g", widgetprofile_handlerslice[2] * 1000.); } #define WIDGETPROFILE_HANDLER_ENTER widgetprofile_handler_enter() @@ -198,7 +198,7 @@ static t_symbol *widget_getcvpathname(t_widget *x, t_glist *glist) t_canvas *cv; if (glist && glist != x->x_glist) { - bug("widget_getcvpathname"); + loudbug_bug("widget_getcvpathname"); x->x_glist = glist; } cv = glist_getcanvas(x->x_glist); @@ -221,37 +221,6 @@ static t_symbol *widget_getmypathname(t_widget *x, t_glist *glist) return (gensym(buf)); } -/* pity cannot set sys_printtostderr... */ -static void widget_postatoms(FILE *fp, char *msg, int ac, t_atom *av) -{ - if (fp) - { - fputs(msg, fp); - while (ac--) - { - char buf[80]; - atom_string(av, buf, 80); - fputc(' ', fp); - fputs(buf, fp); - av++; - } - fputc('\n', fp); - } - else - { - startpost(msg); - while (ac--) - { - if (av->a_type == A_FLOAT) - postfloat(av->a_w.w_float); - else if (av->a_type == A_SYMBOL) - poststring(av->a_w.w_symbol->s_name); - av++; - } - endpost(); - } -} - /* If Tk widget creation fails, gui will send the '_failure' message to the Pd widget object, asking the receiving object to transform itself into a regular text object. Due to the 'bindlist' corruption @@ -273,7 +242,7 @@ static void widget_transtick(t_widget *x) t_atom *hnd = props_getall(x->x_handlers, &nhnd); t_atom *arg = props_getall(x->x_arguments, &narg); if (widget_transforming++) - bug("widget_transtick"); + loudbug_bug("widget_transtick"); binbuf_addv(bb, "sss", gensym("widget"), x->x_type, x->x_name); if (narg) binbuf_add(bb, narg, arg); if (nopt) binbuf_add(bb, nopt, opt); @@ -383,7 +352,7 @@ static void widget_pushoptions(t_widget *x, int doit) else scriptlet_vpush(x->x_transient, "itemoptions"); } else if (!scriptlet_isempty(x->x_optscript)) - bug("widget_pushoptions"); + loudbug_bug("widget_pushoptions"); } static void widget_pushinits(t_widget *x) @@ -395,13 +364,13 @@ static void widget_pushinits(t_widget *x) 0, 0, x->x_arguments)) scriptlet_vpush(x->x_transient, "typeinit"); else if (*widgettype_getinitializer(x->x_typedef, &sz) && sz > 0) - bug("widget_pushinits (type)"); + loudbug_bug("widget_pushinits (type)"); } if (scriptlet_evaluate(x->x_iniscript, x->x_transient, 0, 0, 0, x->x_arguments)) scriptlet_vpush(x->x_transient, "iteminit"); else if (!scriptlet_isempty(x->x_iniscript)) - bug("widget_pushinits (instance)"); + loudbug_bug("widget_pushinits (instance)"); } static void widget_pushconstructors(t_widget *x) @@ -414,7 +383,7 @@ static void widget_pushconstructors(t_widget *x) 0, 0, x->x_arguments)) scriptlet_push(x->x_transient); else if (*widgettype_getconstructor(x->x_typedef, &sz) && sz > 0) - bug("widget_pushconstructors (type)"); + loudbug_bug("widget_pushconstructors (type)"); } } @@ -428,7 +397,7 @@ static void widget_pushdestructors(t_widget *x) 0, 0, x->x_arguments)) scriptlet_push(x->x_transient); else if (*widgettype_getdestructor(x->x_typedef, &sz) && sz > 0) - bug("widget_pushdestructors (type)"); + loudbug_bug("widget_pushdestructors (type)"); } } @@ -606,7 +575,7 @@ static t_symbol *widget_addprops(t_widget *x, t_props *op, int single, } else { - bug("widget_addprops"); + loudbug_bug("widget_addprops"); return (0); } } @@ -852,7 +821,7 @@ static int widget_resettype(t_widget *x, t_widgettype *wt) } else { - bug("widget_resettype"); + loudbug_bug("widget_resettype"); return (0); } } @@ -862,15 +831,12 @@ static void widget_redefine(t_widget *x) widget_resettype(x, widgettype_reload(x->x_type)); } -static void widget__failure(t_widget *x, t_symbol *s, int ac, t_atom *av) +static void widget__failure(t_widget *x) { -#if 0 - /* moved to the gui side -- supporting special chars in error message */ - startpost("tcl error:"); - postatom(ac, av); - endpost(); -#endif loud_error((t_pd *)x, "creation failure"); + /* details printed at the gui side, in order to support special chars + in error message */ + loud_errand((t_pd *)x, "see standard error for details"); x->x_vised = 0; clock_delay(x->x_transclock, 0); } @@ -880,8 +846,8 @@ static void widget__config(t_widget *x, t_symbol *target, t_symbol *bg, t_floatarg fw, t_floatarg fh, t_floatarg fst) { #ifdef WIDGET_DEBUG - post("config %x %s \"%s\" %g %g", - (int)x, target->s_name, bg->s_name, fw, fh); + loudbug_post("config %x %s \"%s\" %g %g", + (int)x, target->s_name, bg->s_name, fw, fh); #endif x->x_width = (int)fw; x->x_height = (int)fh; @@ -893,9 +859,9 @@ static void widget__config(t_widget *x, t_symbol *target, t_symbol *bg, static void widget__value(t_widget *x, t_symbol *s, int ac, t_atom *av) { #ifdef WIDGET_DEBUG - startpost("value:"); - postatom(ac, av); - endpost(); + loudbug_startpost("value:"); + loudbug_postatom(ac, av); + loudbug_endpost(); #endif /* FIXME */ } @@ -979,7 +945,7 @@ static void widget__motion(t_widget *x, t_symbol *s, int ac, t_atom *av) if (x->x_glist->gl_havewindow) /* LATER calculate on-parent coords */ { #if 0 - post("motion %g %g", av[0].a_w.w_float, av[1].a_w.w_float); + loudbug_post("motion %g %g", av[0].a_w.w_float, av[1].a_w.w_float); #endif if (x->x_cvtarget->s_thing) /* LATER rethink */ @@ -1001,6 +967,18 @@ int widget_iswidget(t_gobj *g, t_symbol *type, t_symbol *name) } #ifdef WIDGET_DEBUG +static void widgetbug_postprops(char *msg, t_props *pp) +{ + int ac; + t_atom *av = props_getall(pp, &ac); + if (av) + { + loudbug_startpost(msg); + loudbug_postatom(ac, av); + loudbug_endpost(); + } +} + static void widget_debug(t_widget *x) { t_symbol *pn = widget_getcvpathname(x, 0); @@ -1009,51 +987,43 @@ static void widget_debug(t_widget *x) t_atom *ap; static char bempty[] = ""; char *bp, *key; - fprintf(stderr, "containing glist: %x\n", (int)x->x_glist); - fprintf(stderr, "cv pathname%s %s\n", - (pn ? ":" : ""), (pn ? pn->s_name : "unknown")); - fprintf(stderr, "my pathname%s %s\n", - (mn ? ":" : ""), (mn ? mn->s_name : "unknown")); - if (ap = props_getall(widgettype_getoptions(x->x_typedef), &nopt)) - widget_postatoms(stderr, "default options:", nopt, ap); - if (ap = props_getall(x->x_options, &nopt)) - widget_postatoms(stderr, "instance options:", nopt, ap); - if (ap = props_getall(widgettype_gethandlers(x->x_typedef), &nopt)) - widget_postatoms(stderr, "default handlers:", nopt, ap); - if (ap = props_getall(x->x_handlers, &nopt)) - widget_postatoms(stderr, "instance handlers:", nopt, ap); - if (ap = props_getall(widgettype_getarguments(x->x_typedef), &nopt)) - widget_postatoms(stderr, "default arguments:", nopt, ap); - if (ap = props_getall(x->x_arguments, &nopt)) - widget_postatoms(stderr, "instance arguments:", nopt, ap); - fprintf(stderr, "dictionary:\n"); + loudbug_post("containing glist: %x", (int)x->x_glist); + loudbug_post("cv pathname%s %s", + (pn ? ":" : ""), (pn ? pn->s_name : "unknown")); + loudbug_post("my pathname%s %s", + (mn ? ":" : ""), (mn ? mn->s_name : "unknown")); + widgetbug_postprops("default options:", + widgettype_getoptions(x->x_typedef)); + widgetbug_postprops("instance options:", x->x_options); + widgetbug_postprops("default handlers:", + widgettype_gethandlers(x->x_typedef)); + widgetbug_postprops("instance handlers:", x->x_handlers); + widgetbug_postprops("default arguments:", + widgettype_getarguments(x->x_typedef)); + widgetbug_postprops("instance arguments:", x->x_arguments); + loudbug_post("dictionary:"); bp = props_firstvalue(x->x_arguments, &key); while (bp) { - fprintf(stderr, "\t%s: \"%s\"\n", key, bp); + loudbug_post("\t%s: \"%s\"", key, bp); bp = props_nextvalue(x->x_arguments, &key); } bp = scriptlet_getcontents(x->x_transient, &sz); - fprintf(stderr, "transient buffer (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("transient buffer (size %d):\n\"%s\"", sz, (bp ? bp : bempty)); bp = scriptlet_getcontents(x->x_optscript, &sz); - fprintf(stderr, "option buffer (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("option buffer (size %d):\n\"%s\"", sz, (bp ? bp : bempty)); bp = widgettype_getconstructor(x->x_typedef, &sz); - fprintf(stderr, "type constructor (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("type constructor (size %d):\n\"%s\"", sz, (bp ? bp : bempty)); bp = widgettype_getdestructor(x->x_typedef, &sz); - fprintf(stderr, "type destructor (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("type destructor (size %d):\n\"%s\"", sz, (bp ? bp : bempty)); bp = widgettype_getinitializer(x->x_typedef, &sz); - fprintf(stderr, "type initializer (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("type initializer (size %d):\n\"%s\"", sz, (bp ? bp : bempty)); bp = scriptlet_getcontents(x->x_iniscript, &sz); - fprintf(stderr, "instance initializer (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("instance initializer (size %d):\n\"%s\"", + sz, (bp ? bp : bempty)); bp = masterwidget_getcontents(&sz); - fprintf(stderr, "setup definitions (size %d):\n\"%s\"\n", - sz, (bp ? bp : bempty)); + loudbug_post("setup definitions (size %d):\n\"%s\"", + sz, (bp ? bp : bempty)); } #endif @@ -1245,7 +1215,8 @@ static void tow_widgetattach(t_tow *x, t_widget *w) x->x_widgetlist = we; pd_bind((t_pd *)x, w->x_cbtarget); #ifdef TOW_DEBUG - post("%s widget '%s' attached", w->x_type->s_name, w->x_cbtarget->s_name); + loudbug_post("%s widget '%s' attached", + w->x_type->s_name, w->x_cbtarget->s_name); #endif } @@ -1257,8 +1228,8 @@ static void tow_widgetdetach(t_tow *x, t_widget *w) if (we2->we_widget == w) { #ifdef TOW_DEBUG - post("%s widget '%s' detached by widget's destructor", - w->x_type->s_name, w->x_cbtarget->s_name); + loudbug_post("%s widget '%s' detached by widget's destructor", + w->x_type->s_name, w->x_cbtarget->s_name); #endif pd_unbind((t_pd *)x, w->x_cbtarget); if (we1) @@ -1270,7 +1241,7 @@ static void tow_widgetdetach(t_tow *x, t_widget *w) } we1 = we2; } - bug("tow_widgetdetach"); + loudbug_bug("tow_widgetdetach"); } static void widget_attach(t_widget *x) @@ -1310,12 +1281,12 @@ static void tow_attach(t_tow *x) } #ifdef TOW_DEBUG if (!x->x_widgetlist) - post("%s widget '%s' not found", - x->x_type->s_name, x->x_name->s_name); + loudbug_post("%s widget '%s' not found", + x->x_type->s_name, x->x_name->s_name); #endif } #ifdef TOW_DEBUG - else post("glist '%s' not found", x->x_cvname->s_name); + else loudbug_post("glist '%s' not found", x->x_cvname->s_name); #endif } @@ -1334,8 +1305,8 @@ static void tow_detach(t_tow *x) if (te2->te_tow == x) { #ifdef TOW_DEBUG - post("%s widget '%s' detached by tow's destructor", - w->x_type->s_name, w->x_cbtarget->s_name); + loudbug_post("%s widget '%s' detached by tow's destructor", + w->x_type->s_name, w->x_cbtarget->s_name); #endif if (te1) te1->te_next = te2->te_next; @@ -1346,7 +1317,7 @@ static void tow_detach(t_tow *x) } te1 = te2; } - if (!te2) bug("tow_detach"); + if (!te2) loudbug_bug("tow_detach"); } } @@ -1354,22 +1325,21 @@ static void tow_detach(t_tow *x) static void tow_debug(t_tow *x) { t_widgetentry *we; - fprintf(stderr, "attached widgets:\n"); + loudbug_post("attached widgets:"); for (we = x->x_widgetlist; we; we = we->we_next) { t_widget *w = we->we_widget; t_towentry *te; int other = 0, found = 0; - fprintf(stderr, "\t%s %s", w->x_type->s_name, w->x_cbtarget->s_name); + loudbug_startpost("\t%s %s", w->x_type->s_name, w->x_cbtarget->s_name); for (te = w->x_towlist; te; te = te->te_next) if (te->te_tow == x) found++; else other++; - fprintf(stderr, " (%d other tow%s)\n", other, (other == 1 ? "" : "s")); + loudbug_post(" (%d other tow%s)", other, (other == 1 ? "" : "s")); if (found != 1) - fprintf(stderr, "BUG: listed %d times in widget's towlist\n", - found); + loudbug_bug("listed %d times in widget's towlist", found); } } #endif @@ -1378,7 +1348,7 @@ static void tow_free(t_tow *x) { t_tow *t1, *t2; #ifdef TOW_DEBUG - startpost("updating towlist..."); + loudbug_startpost("updating towlist..."); #endif for (t1 = 0, t2 = towlist; t2; t2 = t2->x_next) { @@ -1389,7 +1359,7 @@ static void tow_free(t_tow *x) else towlist = t2->x_next; #ifdef TOW_DEBUG - post("ok"); + loudbug_post("ok"); #endif break; } @@ -1480,7 +1450,7 @@ void widget_setup(void) class_addmethod(widget_class, (t_method)widget_redefine, gensym("redefine"), 0); class_addmethod(widget_class, (t_method)widget__failure, - gensym("_failure"), A_GIMME, 0); + gensym("_failure"), 0); class_addmethod(widget_class, (t_method)widget__config, gensym("_config"), A_SYMBOL, A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, 0); diff --git a/toxy/widgettype.c b/toxy/widgettype.c index 20ff933..0b993c1 100644 --- a/toxy/widgettype.c +++ b/toxy/widgettype.c @@ -61,14 +61,14 @@ static void widgettype_map(t_widgettype *wt, char *cls, char *pkg) /* only for debugging (never call, unless certain that nobody references wt) */ static void widgettype_free(t_masterwidget *mw, t_widgettype *wt) { - fprintf(stderr, "widgettype free... "); + loudbug_startpost("widgettype free... "); dict_unbind(mw->mw_typemap, (t_pd *)wt, wt->wt_typekey); props_freeall(wt->wt_options); scriptlet_free(wt->wt_iniscript); scriptlet_free(wt->wt_newscript); scriptlet_free(wt->wt_freescript); pd_free((t_pd *)wt); - fprintf(stderr, "done\n"); + loudbug_post("done"); } #endif @@ -141,7 +141,7 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc, typeval = widgettype_new(mw, buf, cls, pkg); mw->mw_parsedtype = typeval; #ifdef WIDGETTYPE_DEBUG - post("adding widget type '%s'", typeval->wt_typekey->s_name); + loudbug_post("adding widget type '%s'", typeval->wt_typekey->s_name); #endif scriptlet_reset(typeval->wt_iniscript); return (typeval->wt_iniscript); @@ -217,7 +217,7 @@ static int widgettype_doload(t_widgettype *wt, t_symbol *s) == SCRIPTLET_OK) { #ifdef WIDGETTYPE_VERBOSE - post("using a separate %s's definition file", s->s_name); + loudbug_post("using a separate %s's definition file", s->s_name); #endif if (!scriptlet_isempty(mwsp)) { @@ -229,7 +229,7 @@ static int widgettype_doload(t_widgettype *wt, t_symbol *s) scriptlet_push(sp); scriptlet_append(masterwidget->mw_setupscript, mwsp); } - else bug("widgettype_doload"); + else loudbug_bug("widgettype_doload"); scriptlet_free(sp); } result = 1; @@ -376,7 +376,7 @@ void masterwidget_validate(void) if (rcresult == SCRIPTLET_OK) { #ifdef WIDGETTYPE_VERBOSE - post("using file 'setup.wid'"); + loudbug_post("using file 'setup.wid'"); #endif } else @@ -410,7 +410,7 @@ void masterwidget_validate(void) } else { - bug("masterwidget_validate 1"); + loudbug_bug("masterwidget_validate 1"); rcresult = SCRIPTLET_BADFILE; } if (rcresult == SCRIPTLET_OK) @@ -421,7 +421,7 @@ void masterwidget_validate(void) if (scriptlet_evaluate(masterwidget->mw_setupscript, sp, 0, 0, 0, 0)) scriptlet_push(sp); else - bug("masterwidget_validate 2"); + loudbug_bug("masterwidget_validate 2"); scriptlet_free(sp); } } -- cgit v1.2.1