aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/Makefile.dirs2
-rw-r--r--shared/common/Makefile.sources1
-rw-r--r--shared/common/clc.c1
-rw-r--r--shared/common/dict.c2
-rw-r--r--shared/common/fitter.c195
-rw-r--r--shared/common/fitter.h20
-rw-r--r--shared/common/grow.c2
-rw-r--r--shared/common/lex.c2
-rw-r--r--shared/common/loud.c184
-rw-r--r--shared/common/loud.h16
-rw-r--r--shared/common/mifi.c111
-rw-r--r--shared/common/mifi.h51
-rw-r--r--shared/common/port.c43
-rw-r--r--shared/common/props.c2
-rw-r--r--shared/common/qtree.c89
-rw-r--r--shared/common/rand.c2
-rw-r--r--shared/common/vefl.c4
-rw-r--r--shared/getridof.baddeps1
-rw-r--r--shared/sickle/arsic.c7
-rw-r--r--shared/sickle/sic.c9
-rw-r--r--shared/toxy/plusbob.c22
-rw-r--r--shared/toxy/scriptlet.c13
22 files changed, 503 insertions, 276 deletions
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 <math.h>
+#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 <stdio.h>
#include <string.h>
#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 <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#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 <string.h>
#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 <string.h>
#include <errno.h>
#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 <string.h>
#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 <time.h>
#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 <string.h>
#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;
}
}