[PD-cvs] externals/miXed/shared/common fitter.c,NONE,1.1 fitter.h,NONE,1.1 Makefile.sources,1.4,1.5 clc.c,1.1,1.2 dict.c,1.3,1.4 grow.c,1.1.1.1,1.2 lex.c,1.1,1.2 loud.c,1.4,1.5 loud.h,1.4,1.5 mifi.c,1.4,1.5 mifi.h,1.3,1.4 port.c,1.15,1.16 props.c,1.3,1.4 qtree.c,1.1,1.2 rand.c,1.2,1.3 vefl.c,1.2,1.3

Krzysztof Czaja krzyszcz at users.sourceforge.net
Tue Jan 11 11:33:23 CET 2005


Update of /cvsroot/pure-data/externals/miXed/shared/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23957/shared/common

Modified Files:
	Makefile.sources clc.c dict.c grow.c lex.c loud.c loud.h 
	mifi.c mifi.h port.c props.c qtree.c rand.c vefl.c 
Added Files:
	fitter.c fitter.h 
Log Message:
svf~: args parsing; prepend/Append: bang handling; seq: pause, continue, goto; many maxmode changes

Index: rand.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/rand.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rand.c	20 Apr 2004 13:55:28 -0000	1.2
--- rand.c	11 Jan 2005 10:33:21 -0000	1.3
***************
*** 6,10 ****
  #include "m_pd.h"
  EXTERN double sys_getrealtime(void);  /* used to be in m_imp.h */
! #include "common/rand.h"
  
  /* borrowed from x_misc.c, LATER rethink */
--- 6,10 ----
  #include "m_pd.h"
  EXTERN double sys_getrealtime(void);  /* used to be in m_imp.h */
! #include "rand.h"
  
  /* borrowed from x_misc.c, LATER rethink */

--- NEW FILE: fitter.c ---
/* 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);
}

Index: Makefile.sources
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/Makefile.sources,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile.sources	8 Dec 2004 15:40:12 -0000	1.4
--- Makefile.sources	11 Jan 2005 10:33:21 -0000	1.5
***************
*** 4,7 ****
--- 4,8 ----
  dict.c \
  fi.c \
+ fitter.c \
  grow.c \
  lex.c \

--- NEW FILE: fitter.h ---
/* 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

Index: port.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** port.c	10 Dec 2004 20:47:03 -0000	1.15
--- port.c	11 Jan 2005 10:33:21 -0000	1.16
***************
*** 25,29 ****
  #include "common/grow.h"
  #include "common/binport.h"
! #include "common/port.h"
  
  #ifdef KRZYSZCZ
--- 25,29 ----
  #include "common/grow.h"
  #include "common/binport.h"
! #include "port.h"
  
  #ifdef KRZYSZCZ
***************
*** 228,232 ****
  {
      t_symbol *sel = port_getsymbol(x, 0);
!     if (sel == &s_) bug("port_gettarget");
      return (sel);
  }
--- 228,232 ----
  {
      t_symbol *sel = port_getsymbol(x, 0);
!     if (sel == &s_) loudbug_bug("port_gettarget");
      return (sel);
  }
***************
*** 235,239 ****
  {
      t_symbol *sel = port_getanysymbol(x, 1);
!     if (sel == &s_) bug("port_getselector");
      return (sel);
  }
--- 235,239 ----
  {
      t_symbol *sel = port_getanysymbol(x, 1);
!     if (sel == &s_) loudbug_bug("port_getselector");
      return (sel);
  }
***************
*** 512,516 ****
  	else
  	{
! 	    bug("import_addclassname");
  	    SETSYMBOL(&at, gensym("???"));
  	}
--- 512,516 ----
  	else
  	{
! 	    loudbug_bug("import_addclassname");
  	    SETSYMBOL(&at, gensym("???"));
  	}
***************
*** 589,595 ****
      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);
  #endif
      import_emaddv(x, portps_vtable, "si;", gensym("size"), x->x_emsize);
--- 589,596 ----
      import_emstart(x, portps_vtable, port_getsymbol(x, 9), port_getint(x, 2));
  #ifdef PORT_DEBUG
!     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);
***************
*** 1169,1173 ****
  	}
      }
!     else bug("port_doparse");
      return (PORT_UNKNOWN);
  }
--- 1170,1174 ----
  	}
      }
!     else loudbug_bug("port_doparse");
      return (PORT_UNKNOWN);
  }
***************
*** 1183,1187 ****
  {
  #ifdef PORT_DEBUG
!     post("parsing...");
  #endif
      x->x_messcount = 0;
--- 1184,1188 ----
  {
  #ifdef PORT_DEBUG
!     loudbug_post("parsing...");
  #endif
      x->x_messcount = 0;
***************
*** 1214,1218 ****
      }
  #ifdef PORT_DEBUG
!     post("end of parsing");
  #endif
  }
--- 1215,1219 ----
      }
  #ifdef PORT_DEBUG
!     loudbug_post("end of parsing");
  #endif
  }
***************
*** 1261,1265 ****
      {
  #ifdef PORT_DEBUG
! 	post("bogus_tick: unbinding '%x'", (int)x);
  #endif
  	pd_unbind((t_pd *)x, portps_cleanup);
--- 1262,1266 ----
      {
  #ifdef PORT_DEBUG
! 	loudbug_post("bogus_tick: unbinding '%x'", (int)x);
  #endif
  	pd_unbind((t_pd *)x, portps_cleanup);
***************
*** 1287,1292 ****
  	    int i;
  #ifdef PORT_DEBUG
! 	    startpost("self-adjusting");
! 	    binbuf_print(t->te_binbuf);
  #endif
  	    binbuf_add(bb, ac - 1, av + 1);
--- 1288,1293 ----
  	    int i;
  #ifdef PORT_DEBUG
! 	    loudbug_startpost("self-adjusting ");
! 	    loudbug_postbinbuf(t->te_binbuf);
  #endif
  	    binbuf_add(bb, ac - 1, av + 1);
***************
*** 1303,1307 ****
  	    }
  #ifdef PORT_DEBUG
! 	    post("%d inlets deleted", BOGUS_NINLETS - i);
  #endif
  	    for (i = 0, op = x->x_outlets + BOGUS_NOUTLETS - 1;
--- 1304,1308 ----
  	    }
  #ifdef PORT_DEBUG
! 	    loudbug_post("%d inlets deleted", BOGUS_NINLETS - i);
  #endif
  	    for (i = 0, op = x->x_outlets + BOGUS_NOUTLETS - 1;
***************
*** 1314,1322 ****
  	    }
  #ifdef PORT_DEBUG
! 	    post("%d outlets deleted", i);
  #endif
  	    glist_retext(x->x_glist, t);
  	}
! 	else bug("bogus_cleanup");
  	x->x_glist = 0;
  	clock_delay(x->x_clock, 0);
--- 1315,1323 ----
  	    }
  #ifdef PORT_DEBUG
! 	    loudbug_post("%d outlets deleted", i);
  #endif
  	    glist_retext(x->x_glist, t);
  	}
! 	else loudbug_bug("bogus_cleanup");
  	x->x_glist = 0;
  	clock_delay(x->x_clock, 0);
***************
*** 1349,1353 ****
  		y->x_clock = clock_new(y, (t_method)bogushook_tick);
  #ifdef PORT_DEBUG
! 		post("reclaiming %s", av->a_w.w_symbol->s_name);
  #endif
  		return (z);
--- 1350,1354 ----
  		y->x_clock = clock_new(y, (t_method)bogushook_tick);
  #ifdef PORT_DEBUG
! 		loudbug_post("reclaiming %s", av->a_w.w_symbol->s_name);
  #endif
  		return (z);
***************
*** 1381,1386 ****
  	    t_binbuf *bb = binbuf_new();
  #ifdef PORT_DEBUG
! 	    startpost("hook-adjusting");
! 	    binbuf_print(t->te_binbuf);
  #endif
  	    ac--; av++;
--- 1382,1387 ----
  	    t_binbuf *bb = binbuf_new();
  #ifdef PORT_DEBUG
! 	    loudbug_startpost("hook-adjusting ");
! 	    loudbug_postbinbuf(t->te_binbuf);
  #endif
  	    ac--; av++;
***************
*** 1413,1417 ****
  	    }
  	}
! 	else bug("bogushook_cleanup");
  	x->x_glist = 0;
  	clock_delay(x->x_clock, 0);
--- 1414,1418 ----
  	    }
  	}
! 	else loudbug_bug("bogushook_cleanup");
  	x->x_glist = 0;
  	clock_delay(x->x_clock, 0);
***************
*** 1422,1426 ****
  {
  #ifdef PORT_DEBUG
!     post("destroing the hook of '%s'", class_getname(*x->x_who));
  #endif
      pd_unbind((t_pd *)x, portps_cleanup);
--- 1423,1427 ----
  {
  #ifdef PORT_DEBUG
!     loudbug_post("destroing the hook of '%s'", class_getname(*x->x_who));
  #endif
      pd_unbind((t_pd *)x, portps_cleanup);

Index: loud.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/loud.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** loud.c	8 Dec 2004 15:40:12 -0000	1.4
--- loud.c	11 Jan 2005 10:33:21 -0000	1.5
***************
*** 1,3 ****
! /* Copyright (c) 2002-2004 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* 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.  */
***************
*** 8,98 ****
  #include <errno.h>
  #include "m_pd.h"
! #include "common/loud.h"
  
  /* 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)
  {
--- 8,20 ----
  #include <errno.h>
  #include "m_pd.h"
! #include "loud.h"
! 
! #ifdef MSW
! #define vsnprintf  _vsnprintf
! #endif
  
  /* The 'shared_' calls do not really belong here,
     LATER find them a permanent home. */
  
  int shared_matchignorecase(char *test, char *pattern)
  {
***************
*** 227,249 ****
  }
  
- 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,
--- 149,152 ----
***************
*** 284,289 ****
  		    loud_warning(&c, 0, "%s rounded up to %g", what, minval);
  		else
! 		    loud_incompatible(c, "less than %g %s requested",
! 				      minval, what);
  	    }
  	    break;
--- 187,192 ----
  		    loud_warning(&c, 0, "%s rounded up to %g", what, minval);
  		else
! 		    loud_warning(&c, 0, "less than %g %s requested",
! 				 minval, what);
  	    }
  	    break;
***************
*** 294,299 ****
  		    loud_warning(&c, 0, "%s truncated to %g", what, maxval);
  		else
! 		    loud_incompatible(c, "more than %g %s requested",
! 				      maxval, what);
  	    }
  	    break;
--- 197,202 ----
  		    loud_warning(&c, 0, "%s truncated to %g", what, maxval);
  		else
! 		    loud_warning(&c, 0, "more than %g %s requested",
! 				 maxval, what);
  	    }
  	    break;
***************
*** 437,438 ****
--- 340,408 ----
      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);
+ }

Index: props.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/props.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** props.c	10 Dec 2004 20:47:03 -0000	1.3
--- props.c	11 Jan 2005 10:33:21 -0000	1.4
***************
*** 6,10 ****
  #include "m_pd.h"
  #include "common/grow.h"
! #include "common/props.h"
  
  #ifdef KRZYSZCZ
--- 6,10 ----
  #include "m_pd.h"
  #include "common/grow.h"
! #include "props.h"
  
  #ifdef KRZYSZCZ

Index: mifi.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/mifi.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mifi.h	8 Dec 2004 15:40:12 -0000	1.3
--- mifi.h	11 Jan 2005 10:33:21 -0000	1.4
***************
*** 1,3 ****
! /* Copyright (c) 2004 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* 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.  */
***************
*** 22,48 ****
  #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 */
  
  /* ...channel status codes go here, too obvious to #define... */
  
! #define MIFISYSEX_FIRST      0xf0
! #define MIFISYSEX_NEXT       0xf7
  
  /* this code is not returned as an event type, but in e_status of t_mifievent */
! #define MIFIEVENT_META       0xff
  
  /* true if one of channel messages */
--- 22,61 ----
  #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 (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_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
! 
! /* 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 */

Index: vefl.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/vefl.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vefl.c	10 Dec 2004 20:47:03 -0000	1.2
--- vefl.c	11 Jan 2005 10:33:21 -0000	1.3
***************
*** 18,22 ****
  #include "unstable/fragile.h"
  #include "common/loud.h"
! #include "common/vefl.h"
  
  #ifdef KRZYSZCZ
--- 18,22 ----
  #include "unstable/fragile.h"
  #include "common/loud.h"
! #include "vefl.h"
  
  #ifdef KRZYSZCZ
***************
*** 70,74 ****
      if (sizeof(t_word) != sizeof(t_float))
      {
! 	bug("vefl_new: sizeof(t_word) != sizeof(t_float)");
  	return (0);
      }
--- 70,74 ----
      if (sizeof(t_word) != sizeof(t_float))
      {
! 	loudbug_bug("vefl_new: sizeof(t_word) != sizeof(t_float)");
  	return (0);
      }

Index: qtree.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/qtree.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** qtree.c	8 Dec 2004 15:45:25 -0000	1.1
--- qtree.c	11 Jan 2005 10:33:21 -0000	1.2
***************
*** 4,7 ****
--- 4,8 ----
  
  #include "m_pd.h"
+ #include "loud.h"
  #include "qtree.h"
  
***************
*** 27,31 ****
  	    /* failure: two paths rooted in the same node
  	       contain different number of black nodes */
! 	    bug("qnode_verify: not balanced");
  	    return (0);
  	}
--- 28,32 ----
  	    /* failure: two paths rooted in the same node
  	       contain different number of black nodes */
! 	    loudbug_bug("qnode_verify: not balanced");
  	    return (0);
  	}
***************
*** 37,41 ****
  		(np->n_right && !np->n_right->n_black))
  	    {
! 		bug("qnode_verify: adjacent red nodes");
  		return (0);
  	    }
--- 38,42 ----
  		(np->n_right && !np->n_right->n_black))
  	    {
! 		loudbug_bug("qnode_verify: adjacent red nodes");
  		return (0);
  	    }
***************
*** 57,61 ****
      {
  	if (np1 == np2)
! 	    bug("qnode_checkmulti");
  	else
  	    return (1);
--- 58,62 ----
      {
  	if (np1 == np2)
! 	    loudbug_bug("qnode_checkmulti");
  	else
  	    return (1);
***************
*** 67,82 ****
  		       t_qnode_vshowhook hook, char *message)
  {
!     startpost("%g ", np->n_key);
      if (tree->t_valuetype == QTREETYPE_FLOAT)
! 	startpost("%g ", QNODE_GETFLOAT(np));
      else if (tree->t_valuetype == QTREETYPE_SYMBOL)
! 	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);
  	else if (ap->a_type == A_SYMBOL)
! 	    startpost("%s ", ap->a_w.w_symbol->s_name);
      }
      else if (hook)
--- 68,83 ----
  		       t_qnode_vshowhook hook, char *message)
  {
!     loudbug_startpost("%g ", np->n_key);
      if (tree->t_valuetype == QTREETYPE_FLOAT)
! 	loudbug_startpost("%g ", QNODE_GETFLOAT(np));
      else if (tree->t_valuetype == QTREETYPE_SYMBOL)
! 	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)
! 	    loudbug_startpost("%g ", ap->a_w.w_float);
  	else if (ap->a_type == A_SYMBOL)
! 	    loudbug_startpost("%s ", ap->a_w.w_symbol->s_name);
      }
      else if (hook)
***************
*** 84,91 ****
  	char buf[MAXPDSTRING];
  	(*hook)(np, buf, MAXPDSTRING);
! 	startpost("%s ", buf);
      }
!     else startpost("0x%08x ", (int)QNODE_GETSYMBOL(np));
!     startpost("%s ", (np->n_black ? "black" : "red"));
  
      if (qnode_checkmulti(np, np->n_parent) ||
--- 85,92 ----
  	char buf[MAXPDSTRING];
  	(*hook)(np, buf, MAXPDSTRING);
! 	loudbug_startpost("%s ", buf);
      }
!     else loudbug_startpost("0x%08x ", (int)QNODE_GETSYMBOL(np));
!     loudbug_startpost("%s ", (np->n_black ? "black" : "red"));
  
      if (qnode_checkmulti(np, np->n_parent) ||
***************
*** 95,116 ****
  	qnode_checkmulti(np->n_parent, np->n_right) ||
  	qnode_checkmulti(np->n_left, np->n_right))
! 	startpost("multi ");
  
      if (np->n_parent)
! 	startpost("(%g -> ", np->n_parent->n_key);
      else
! 	startpost("(nul -> ");
      if (np->n_left)
! 	startpost("%g, ", np->n_left->n_key);
      else
! 	startpost("nul, ");
      if (np->n_right)
! 	startpost("%g)", np->n_right->n_key);
      else
! 	startpost("nul)");
      if (message)
! 	post(": %s", message);
      else
! 	endpost();
  }
  
--- 96,117 ----
  	qnode_checkmulti(np->n_parent, np->n_right) ||
  	qnode_checkmulti(np->n_left, np->n_right))
! 	loudbug_startpost("multi ");
  
      if (np->n_parent)
! 	loudbug_startpost("(%g -> ", np->n_parent->n_key);
      else
! 	loudbug_startpost("(nul -> ");
      if (np->n_left)
! 	loudbug_startpost("%g, ", np->n_left->n_key);
      else
! 	loudbug_startpost("nul, ");
      if (np->n_right)
! 	loudbug_startpost("%g)", np->n_right->n_key);
      else
! 	loudbug_startpost("nul)");
      if (message)
! 	loudbug_post(": %s", message);
      else
! 	loudbug_endpost();
  }
  
***************
*** 137,146 ****
  		else
  		{
! 		    bug("qtree_checktraversal 1");
  		    qnode_post(tree, treewalk, 0, "treewalk");
  		    if (listwalk)
  			qnode_post(tree, listwalk, 0, "listwalk");
  		    else
! 			post("empty listwalk pointer");
  		    listwalk = treewalk;
  		}
--- 138,147 ----
  		else
  		{
! 		    loudbug_bug("qtree_checktraversal 1");
  		    qnode_post(tree, treewalk, 0, "treewalk");
  		    if (listwalk)
  			qnode_post(tree, listwalk, 0, "listwalk");
  		    else
! 			loudbug_post("empty listwalk pointer");
  		    listwalk = treewalk;
  		}
***************
*** 160,169 ****
  	    else
  	    {
! 		bug("qtree_checktraversal 2");
  		qnode_post(tree, treewalk, 0, "treewalk");
  		if (listwalk)
  		    qnode_post(tree, listwalk, 0, "listwalk");
  		else
! 		    post("empty listwalk pointer");
  		listwalk = treewalk;
  	    }
--- 161,170 ----
  	    else
  	    {
! 		loudbug_bug("qtree_checktraversal 2");
  		qnode_post(tree, treewalk, 0, "treewalk");
  		if (listwalk)
  		    qnode_post(tree, listwalk, 0, "listwalk");
  		else
! 		    loudbug_post("empty listwalk pointer");
  		listwalk = treewalk;
  	    }
***************
*** 189,193 ****
      t_qnode *np;
      int count;
!     post("------------------------");
      count = qtree_checktraversal(tree);
      if (level)
--- 190,194 ----
      t_qnode *np;
      int count;
!     loudbug_post("------------------------");
      count = qtree_checktraversal(tree);
      if (level)
***************
*** 197,204 ****
  	if (level > 1)
  	{
! 	    post("************");
  	    for (np = tree->t_last; np; np = np->n_prev)
! 		startpost("%g ", np->n_key);
! 	    endpost();
  	}
      }
--- 198,205 ----
  	if (level > 1)
  	{
! 	    loudbug_post("************");
  	    for (np = tree->t_last; np; np = np->n_prev)
! 		loudbug_startpost("%g ", np->n_key);
! 	    loudbug_endpost();
  	}
      }
***************
*** 210,222 ****
  	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);
      }
!     else post("empty");
!     post("...verified (black-height is %d)", qtree_verify(tree));
!     post("------------------------");
  }
  #endif
--- 211,223 ----
  	while (last->n_right && last->n_right != tree->t_root)
  	    last = last->n_right;
! 	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 loudbug_post("empty");
!     loudbug_post("...verified (black-height is %d)", qtree_verify(tree));
!     loudbug_post("------------------------");
  }
  #endif
***************
*** 264,268 ****
  	{
  	    /* LATER revisit */
! 	    bug("qtree_preinserthook");
  	    return (0);  /* do nothing */
  	}
--- 265,269 ----
  	{
  	    /* LATER revisit */
! 	    loudbug_bug("qtree_preinserthook");
  	    return (0);  /* do nothing */
  	}
***************
*** 281,285 ****
  	{
  	    /* LATER revisit */
! 	    bug("qtree_postinserthook");
  	    return (0);  /* do nothing */
  	}
--- 282,286 ----
  	{
  	    /* LATER revisit */
! 	    loudbug_bug("qtree_postinserthook");
  	    return (0);  /* do nothing */
  	}
***************
*** 319,323 ****
  		if (parent->n_left && parent->n_right)
  		{
! 		    bug("qtree_insert, callback return 1");
  		    parent = parent->n_next;
  		}
--- 320,324 ----
  		if (parent->n_left && parent->n_right)
  		{
! 		    loudbug_bug("qtree_insert, callback return 1");
  		    parent = parent->n_next;
  		}
***************
*** 326,330 ****
  		    if (parent->n_left)
  		    {
! 			bug("qtree_insert, callback return 2");
  			leftchild = 0;
  		    }
--- 327,331 ----
  		    if (parent->n_left)
  		    {
! 			loudbug_bug("qtree_insert, callback return 2");
  			leftchild = 0;
  		    }
***************
*** 686,690 ****
  	    SETFLOAT(ap, f);
  	}
! 	else bug("qtree_insertfloat");
      }
      return (np);
--- 687,691 ----
  	    SETFLOAT(ap, f);
  	}
! 	else loudbug_bug("qtree_insertfloat");
      }
      return (np);
***************
*** 709,713 ****
  	    SETSYMBOL(ap, s);
  	}
! 	else bug("qtree_insertsymbol");
      }
      return (np);
--- 710,714 ----
  	    SETSYMBOL(ap, s);
  	}
! 	else loudbug_bug("qtree_insertsymbol");
      }
      return (np);
***************
*** 726,730 ****
  	    npa->na_value = *ap;
  	}
! 	else bug("qtree_insertatom");
      }
      return (np);
--- 727,731 ----
  	    npa->na_value = *ap;
  	}
! 	else loudbug_bug("qtree_insertatom");
      }
      return (np);
***************
*** 755,759 ****
  	break;
      default:
! 	bug("qtree_inittyped");
  	vtype = QTREETYPE_ILLEGAL;
  	nsize = sizeof(t_qnode);
--- 756,760 ----
  	break;
      default:
! 	loudbug_bug("qtree_inittyped");
  	vtype = QTREETYPE_ILLEGAL;
  	nsize = sizeof(t_qnode);

Index: clc.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/clc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** clc.c	8 Dec 2004 15:45:25 -0000	1.1
--- clc.c	11 Jan 2005 10:33:21 -0000	1.2
***************
*** 4,7 ****
--- 4,8 ----
  
  #include <math.h>
+ #include "clc.h"
  
  /* Problem:  find a function f : p -> q (where p is user's curve control

Index: lex.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/lex.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lex.c	8 Dec 2004 15:45:25 -0000	1.1
--- lex.c	11 Jan 2005 10:33:21 -0000	1.2
***************
*** 11,15 ****
  #include "m_pd.h"
  #endif
! #include "common/lex.h"
  
  static int lex_nextbyte(t_lex *lx, unsigned char *buf)
--- 11,15 ----
  #include "m_pd.h"
  #endif
! #include "lex.h"
  
  static int lex_nextbyte(t_lex *lx, unsigned char *buf)

Index: loud.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/loud.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** loud.h	8 Dec 2004 15:40:12 -0000	1.4
--- loud.h	11 Jan 2005 10:33:21 -0000	1.5
***************
*** 1,3 ****
! /* Copyright (c) 2002-2004 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* 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.  */
***************
*** 14,22 ****
  #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);
  
--- 14,17 ----
***************
*** 31,36 ****
  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,
--- 26,29 ----
***************
*** 51,53 ****
--- 44,53 ----
  				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

Index: grow.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/grow.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** grow.c	23 May 2003 12:29:52 -0000	1.1.1.1
--- grow.c	11 Jan 2005 10:33:21 -0000	1.2
***************
*** 7,11 ****
  #include <string.h>
  #include "m_pd.h"
! #include "common/grow.h"
  
  /* Prior to this call a caller is supposed to check for *nrequested > *sizep.
--- 7,11 ----
  #include <string.h>
  #include "m_pd.h"
! #include "grow.h"
  
  /* Prior to this call a caller is supposed to check for *nrequested > *sizep.

Index: mifi.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/mifi.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mifi.c	10 Dec 2004 20:47:03 -0000	1.4
--- mifi.c	11 Jan 2005 10:33:21 -0000	1.5
***************
*** 1,3 ****
! /* Copyright (c) 2004 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
--- 1,3 ----
! /* 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.  */
***************
*** 71,75 ****
  
  #ifdef KRZYSZCZ
! #define MIFI_DEBUG
  #endif
  #define MIFI_VERBOSE
--- 71,78 ----
  
  #ifdef KRZYSZCZ
! # include "loud.h"
! # define MIFI_DEBUG
! #else
! # define loudbug_bug(msg)  fprintf(stderr, "BUG: %s\n", msg), bug(msg)
  #endif
  #define MIFI_VERBOSE
***************
*** 90,95 ****
  #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 */
  
  typedef struct _mifievent
--- 93,99 ----
  #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_MAXSYSEX  256  /* FIXME */
  
  typedef struct _mifievent
***************
*** 295,299 ****
      if (type > 127)
      {
! 	bug("mifievent_settext");
  	return (0);
      }
--- 299,303 ----
      if (type > 127)
      {
! 	loudbug_bug("mifievent_settext");
  	return (0);
      }
***************
*** 313,324 ****
  
  #ifdef MIFI_DEBUG
! static void mifievent_printsysex(t_mifievent *ep)
  {
!     int length = ep->e_length;
!     uchar *dp = ep->e_data;
!     startpost("sysex:");
      while (length--)
! 	postfloat((float)*dp++);
!     endpost();
  }
  #endif
--- 317,331 ----
  
  #ifdef MIFI_DEBUG
! static void mifi_printsysex(int length, uchar *buf)
  {
!     loudbug_startpost("sysex:");
      while (length--)
! 	loudbug_startpost(" %d", (int)*buf++);
!     loudbug_endpost();
! }
! 
! static void mifievent_printsysex(t_mifievent *ep)
! {
!     mifi_printsysex(ep->e_length, ep->e_data);
  }
  #endif
***************
*** 350,359 ****
      {
  	int tempo = mifi_swap4(*(uint32 *)ep->e_data);
! 	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);
      }
  #endif
--- 357,366 ----
      {
  	int tempo = mifi_swap4(*(uint32 *)ep->e_data);
! 	loudbug_post("tempo (hard) %d after %d", tempo, ep->e_delay);
      }
      else if (ep->e_meta == MIFIMETA_TIMESIG)
      {
! 	loudbug_post("meter %d/%d after %d",
! 		     ep->e_data[0], (1 << ep->e_data[1]), ep->e_delay);
      }
  #endif
***************
*** 471,475 ****
  	if (mr->mr_ticks.rt_tempo < MIFI_TICKEPSILON)
  	{
! 	    bug("mifiread_updateticks");
  	    mr->mr_ticks.rt_tempo = mr->mr_ticks.rt_deftempo;
  	}
--- 478,482 ----
  	if (mr->mr_ticks.rt_tempo < MIFI_TICKEPSILON)
  	{
! 	    loudbug_bug("mifiread_updateticks");
  	    mr->mr_ticks.rt_tempo = mr->mr_ticks.rt_deftempo;
  	}
***************
*** 656,662 ****
      {
  	length = mifiread_getvarlen(mr);
! 	/* FIXME optional read */
! 	if (mifiread_skipbytes(mr, length) < 0)
! 	    return (MIFIREAD_FATAL);
  	goto nextattempt;
      }
--- 663,681 ----
      {
  	length = mifiread_getvarlen(mr);
! 	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;
      }
***************
*** 725,729 ****
  #ifdef MIFI_DEBUG
  	    if (mr->mr_pass == 1)
! 		post("barspan (hard) %g", mr->mr_ticks.rt_hardbar);
  #endif
  	    break;
--- 744,748 ----
  #ifdef MIFI_DEBUG
  	    if (mr->mr_pass == 1)
! 		loudbug_post("barspan (hard) %g", mr->mr_ticks.rt_hardbar);
  #endif
  	    break;
***************
*** 812,821 ****
  #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);
      else
! 	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);
--- 831,841 ----
  #ifdef MIFI_DEBUG
      if (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
! 	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);
***************
*** 851,856 ****
  	if (mr->mr_newtrack)
  	{
! #ifdef MIFI_VERBOSE
! 	    post("track %d", mr->mr_ntracks);
  #endif
  	    isnewtrack = 1;
--- 871,876 ----
  	if (mr->mr_newtrack)
  	{
! #ifdef MIFI_DEBUG
! 	    loudbug_post("track %d", mr->mr_ntracks);
  #endif
  	    isnewtrack = 1;
***************
*** 877,881 ****
  		    *tnamep = gensym(tnamebuf);
  #ifdef MIFI_DEBUG
! 		    post("nonempty track name %s", (*tnamep)->s_name);
  #endif
  		}
--- 897,901 ----
  		    *tnamep = gensym(tnamebuf);
  #ifdef MIFI_DEBUG
! 		    loudbug_post("nonempty track name %s", (*tnamep)->s_name);
  #endif
  		}
***************
*** 884,887 ****
--- 904,908 ----
  	    mr->mr_nevents++;
  	}
+ 	/* FIXME sysex */
  	else if (evtype < 0x80)
  	{
***************
*** 927,930 ****
--- 948,954 ----
  	    }
  	}
+ #ifdef MIFI_VERBOSE
+ 	post("got %d midi tracks (out of %d)", mr->mr_ntracks, mr->mr_hdtracks);
+ #endif
  	return (MIFIREAD_EOF);
      }
***************
*** 952,956 ****
  	    if (ntracks > mr->mr_ntracks)
  	    {
! 		bug("mifiread_doit: too many tracks");
  		goto doitfail;
  	    }
--- 976,980 ----
  	    if (ntracks > mr->mr_ntracks)
  	    {
! 		loudbug_bug("mifiread_doit: too many tracks");
  		goto doitfail;
  	    }
***************
*** 958,962 ****
  		mr->mr_tracknames[mr->mr_trackndx] == &s_)
  	    {
! 		bug("mifiread_doit: empty track name");
  		mr->mr_tracknames[mr->mr_trackndx] = gensym("bug-track");
  	    }
--- 982,986 ----
  		mr->mr_tracknames[mr->mr_trackndx] == &s_)
  	    {
! 		loudbug_bug("mifiread_doit: empty track name");
  		mr->mr_tracknames[mr->mr_trackndx] = gensym("bug-track");
  	    }
***************
*** 969,973 ****
  #ifdef MIFI_DEBUG
  	if (evtype == MIFIREAD_EOF)
! 	    post("finished reading %d events from midi file", mr->mr_nevents);
  #endif
  	return (MIFIREAD_EOF);
--- 993,998 ----
  #ifdef MIFI_DEBUG
  	if (evtype == MIFIREAD_EOF)
! 	    loudbug_post("finished reading %d events from midi file",
! 			 mr->mr_nevents);
  #endif
  	return (MIFIREAD_EOF);
***************
*** 1055,1059 ****
      else
      {
! 	bug("mifiread_gettrackname");
  	return (0);
      }
--- 1080,1084 ----
      else
      {
! 	loudbug_bug("mifiread_gettrackname");
  	return (0);
      }
***************
*** 1063,1067 ****
  {
      if (mr->mr_pass != 2)
! 	bug("mifiread_getstatus");
      return (mr->mr_event.e_status);
  }
--- 1088,1092 ----
  {
      if (mr->mr_pass != 2)
! 	loudbug_bug("mifiread_getstatus");
      return (mr->mr_event.e_status);
  }
***************
*** 1070,1074 ****
  {
      if (mr->mr_pass != 2)
! 	bug("mifiread_getdata1");
      return (mr->mr_event.e_data[0]);
  }
--- 1095,1099 ----
  {
      if (mr->mr_pass != 2)
! 	loudbug_bug("mifiread_getdata1");
      return (mr->mr_event.e_data[0]);
  }
***************
*** 1077,1083 ****
  {
      if (mr->mr_pass != 2)
! 	bug("mifiread_getdata2");
      if (mr->mr_event.e_length < 2)
! 	bug("mifiread_getdata2");
      return (mr->mr_event.e_data[1]);
  }
--- 1102,1108 ----
  {
      if (mr->mr_pass != 2)
! 	loudbug_bug("mifiread_getdata2");
      if (mr->mr_event.e_length < 2)
! 	loudbug_bug("mifiread_getdata2");
      return (mr->mr_event.e_data[1]);
  }
***************
*** 1086,1090 ****
  {
      if (mr->mr_pass != 2)
! 	bug("mifiread_getchannel");
      return (mr->mr_event.e_channel);
  }
--- 1111,1115 ----
  {
      if (mr->mr_pass != 2)
! 	loudbug_bug("mifiread_getchannel");
      return (mr->mr_event.e_channel);
  }
***************
*** 1156,1160 ****
  	if (mw->mw_ticks.wt_tempo < MIFI_TICKEPSILON)
  	{
! 	    bug("mifiwrite_updateticks");
  	    mw->mw_ticks.wt_tempo = mw->mw_ticks.wt_deftempo;
  	}
--- 1181,1185 ----
  	if (mw->mw_ticks.wt_tempo < MIFI_TICKEPSILON)
  	{
! 	    loudbug_bug("mifiwrite_updateticks");
  	    mw->mw_ticks.wt_tempo = mw->mw_ticks.wt_deftempo;
  	}
***************
*** 1268,1272 ****
      if (ntracks < 1 || ntracks > MIFI_MAXTRACKS)
      {
! 	bug("mifiwrite_open 1");
  	complain = 0;
  	goto wopenfailed;
--- 1293,1297 ----
      if (ntracks < 1 || ntracks > MIFI_MAXTRACKS)
      {
! 	loudbug_bug("mifiwrite_open 1");
  	complain = 0;
  	goto wopenfailed;
***************
*** 1278,1282 ****
  	if (mw->mw_ntracks != 1)
  	{  /* LATER consider replacing with a warning */
! 	    bug("mifiwrite_open 2");
  	    complain = 0;
  	    goto wopenfailed;
--- 1303,1307 ----
  	if (mw->mw_ntracks != 1)
  	{  /* LATER consider replacing with a warning */
! 	    loudbug_bug("mifiwrite_open 2");
  	    complain = 0;
  	    goto wopenfailed;
***************
*** 1344,1348 ****
      length = mifi_swap4(mw->mw_trackbytes);
  #ifdef MIFI_DEBUG
!     post("adjusting track size to %d", mw->mw_trackbytes);
  #endif
      /* LATER add sanity check (compare to saved filepos) */
--- 1369,1373 ----
      length = mifi_swap4(mw->mw_trackbytes);
  #ifdef MIFI_DEBUG
!     loudbug_post("adjusting track size to %d", mw->mw_trackbytes);
  #endif
      /* LATER add sanity check (compare to saved filepos) */
***************
*** 1370,1374 ****
      else if (mw->mw_trackndx++ == mw->mw_ntracks)
      {
! 	bug("mifiwrite_opentrack");
  	return (0);
      }
--- 1395,1399 ----
      else if (mw->mw_trackndx++ == mw->mw_ntracks)
      {
! 	loudbug_bug("mifiwrite_opentrack");
  	return (0);
      }
***************
*** 1411,1415 ****
      else
      {
! 	bug("mifiwrite_closetrack");
  	return (0);
      }
--- 1436,1440 ----
      else
      {
! 	loudbug_bug("mifiwrite_closetrack");
  	return (0);
      }
***************
*** 1434,1438 ****
  	|| (!shorter && data2 > 127))
      {
! 	bug("mifiwrite_channelevent");
  	return (0);
      }
--- 1459,1463 ----
  	|| (!shorter && data2 > 127))
      {
! 	loudbug_bug("mifiwrite_channelevent");
  	return (0);
      }

Index: dict.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/dict.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dict.c	10 Dec 2004 20:47:03 -0000	1.3
--- dict.c	11 Jan 2005 10:33:21 -0000	1.4
***************
*** 9,13 ****
  #include <string.h>
  #include "m_pd.h"
! #include "common/dict.h"
  
  #ifdef KRZYSZCZ
--- 9,13 ----
  #include <string.h>
  #include "m_pd.h"
! #include "dict.h"
  
  #ifdef KRZYSZCZ





More information about the Pd-cvs mailing list