[PD-cvs] externals/miXed/shared/common Makefile.sources,1.3,1.4 binport.c,1.5,1.6 binport.h,1.3,1.4 dict.c,1.1,1.2 dict.h,1.1,1.2 loud.c,1.3,1.4 loud.h,1.3,1.4 mifi.c,1.2,1.3 mifi.h,1.2,1.3 port.c,1.13,1.14

Krzysztof Czaja krzyszcz at users.sourceforge.net
Wed Dec 8 16:40:15 CET 2004


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

Modified Files:
	Makefile.sources binport.c binport.h dict.c dict.h loud.c 
	loud.h mifi.c mifi.h port.c 
Log Message:
various bug-fixes, maxmode, toxy .#args

Index: dict.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/dict.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dict.h	26 Sep 2003 07:29:14 -0000	1.1
--- dict.h	8 Dec 2004 15:40:12 -0000	1.2
***************
*** 21,26 ****
  void dict_bind(t_dict *x, t_pd *obj, t_symbol *s);
  void dict_unbind(t_dict *x, t_pd *obj, t_symbol *s);
! t_pd *dict_value(t_dict *x, t_symbol *s);
  t_pd *dict_xvalue(t_dict *x, t_symbol *s);
  int dict_forall(t_dict *x, t_symbol *s, t_dict_hook hook, void *hookarg);
  
--- 21,29 ----
  void dict_bind(t_dict *x, t_pd *obj, t_symbol *s);
  void dict_unbind(t_dict *x, t_pd *obj, t_symbol *s);
! t_pd *dict_firstvalue(t_dict *dict, t_symbol *s, void **nextp);
! t_pd *dict_nextvalue(t_dict *dict, t_symbol *s, void **nextp);
! #if 0
  t_pd *dict_xvalue(t_dict *x, t_symbol *s);
+ #endif
  int dict_forall(t_dict *x, t_symbol *s, t_dict_hook hook, void *hookarg);
  

Index: mifi.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/mifi.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** mifi.h	14 Aug 2003 14:26:06 -0000	1.2
--- mifi.h	8 Dec 2004 15:40:12 -0000	1.3
***************
*** 1,84 ****
! /* Copyright (c) 2001-2003 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
  
- /* reading/writing midifiles, a prototype version */
- 
  #ifndef __MIFI_H__
  #define __MIFI_H__
  
! /* event types, as returned by mifi_read_event() */
! #define MIFI_READ_FATAL  -3  /* unexpected eof, error in last track, or file error */
! #define MIFI_READ_EOF    -2  /* regular eof */
! #define MIFI_READ_SKIP   -1  /* error and successful skip to the next track */
! #define MIFI_META_SEQNUM         0
! #define MIFI_META_TEXT           1
! #define MIFI_META_COPYRIGHT      2
! #define MIFI_META_TRACKNAME      3
! #define MIFI_META_INSTRUMENT     4
! #define MIFI_META_LYRIC          5
! #define MIFI_META_MARKER         6
! #define MIFI_META_CUE            7
! #define MIFI_META_MAXPRINTABLE  15  /* 1..15 are various text meta-events */
! #define MIFI_META_CHANNEL     0x20  /* channel prefix */
! #define MIFI_META_EOT         0x2f  /* end of track */
! #define MIFI_META_TEMPO       0x51
! #define MIFI_META_SMPTE       0x54  /* SMPTE offset */
! #define MIFI_META_TIMESIG     0x58  /* time signature */
! #define MIFI_META_KEYSIG      0x59  /* key signature */
! /* ...channel status codes go here, too obvious to #define... */
! #define MIFI_SYSEX_FIRST      0xf0
! #define MIFI_SYSEX_NEXT       0xf7
! /* this code is not returned as an event type, but in e_status of t_mifi_event */
! #define MIFI_EVENT_META       0xff
  
! /* true if one of channel messages */
! #define MIFI_IS_CHANNEL(status)    (((status) & 0x80) && (status) < 0xf0)
! /* true if one of the two shorter channel messages */
! #define MIFI_ONE_DATABYTE(status)  (((status) & 0xe0) == 0xc0)
  
! /* derived from t_squeve */
! typedef struct _mifi_event
! {
!     uint32  e_length;
!     uchar  *e_data;
!     size_t  e_bufsize;
!     uint32  e_delay;
!     uchar   e_status;
!     uchar   e_channel;
!     uchar   e_meta;      /* meta-event type */
! } t_mifi_event;
  
! /* This structure holds midi data stream properties, i.e. both the info stored
!    in midifile header, and the current state according to position in a stream. */
! /* LATER clean up t_sq and derive t_mifi_stream */
! typedef struct _sq t_mifi_stream;
  
! /* prototypes of public interface routines */
  
! t_mifi_event *mifi_event_new(void);
! void mifi_event_free(t_mifi_event *ep);
! int mifi_event_settext(t_mifi_event *ep, int type, char *text);
! void mifi_event_printmeta(t_mifi_event *ep);
  
! t_mifi_stream *mifi_stream_new(void);
! void mifi_stream_reset(t_mifi_stream *sp);
! void mifi_stream_free(t_mifi_stream *sp);
  
! t_mifi_stream *mifi_read_start(t_mifi_stream *sp,
! 			       const char *filename, const char *dirname,
! 			       int complain);
! int mifi_read_restart(t_mifi_stream *sp);
! void mifi_read_end(t_mifi_stream *sp);
! int mifi_read_event(t_mifi_stream *sp, t_mifi_event *ep);
! int mifi_read_analyse(t_mifi_stream *sp);
! int mifi_read_doit(t_mifi_stream *sp);
  
! t_mifi_stream *mifi_write_start(t_mifi_stream *sp,
! 				const char *filename, const char *dirname);
! void mifi_write_end(t_mifi_stream *sp);
! int mifi_write_start_track(t_mifi_stream *sp);
! int mifi_write_adjust_track(t_mifi_stream *sp, uint32 eotdelay);
! int mifi_write_event(t_mifi_stream *sp, t_mifi_event *ep);
  
  #endif
--- 1,97 ----
! /* 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.  */
  
  #ifndef __MIFI_H__
  #define __MIFI_H__
  
! EXTERN_STRUCT _mifiread;
! #define t_mifiread  struct _mifiread
! EXTERN_STRUCT _mifiwrite;
! #define t_mifiwrite  struct _mifiwrite
  
! typedef int (*t_mifireadhook)(t_mifiread *mf, void *hookdata, int evtype);
  
! #define MIFI_MAXTRACKS     0x7fff
! #define MIFI_MAXBEATTICKS  0x7fff
  
! /* event types, as returned by mifiread_nextevent(), ... */
  
! #define MIFIREAD_FATAL  -3  /* unexpected eof, last track's or file error */
! #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 */
  
! /* ...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 */
! #define MIFI_ISCHANNEL(status)    (((status) & 0x80) && (status) < 0xf0)
! /* true if one of the two shorter channel messages */
! #define MIFI_ONEDATABYTE(status)  (((status) & 0xe0) == 0xc0)
! 
! int mifiread_getnevents(t_mifiread *mr);
! int mifiread_getntempi(t_mifiread *mr);
! int mifiread_gethdtracks(t_mifiread *mr);
! int mifiread_getformat(t_mifiread *mr);
! int mifiread_getnframes(t_mifiread *mr);
! int mifiread_getbeatticks(t_mifiread *mr);
! double mifiread_getdeftempo(t_mifiread *mr);
! 
! int mifiread_getbarindex(t_mifiread *mr);
! double mifiread_getbarspan(t_mifiread *mr);
! double mifiread_gettick(t_mifiread *mr);
! double mifiread_getscoretime(t_mifiread *mr);
! double mifiread_gettempo(t_mifiread *mr);
! double mifiread_getmscoef(t_mifiread *mr);
! t_symbol *mifiread_gettrackname(t_mifiread *mr);
! unsigned mifiread_getstatus(t_mifiread *mr);
! unsigned mifiread_getdata1(t_mifiread *mr);
! unsigned mifiread_getdata2(t_mifiread *mr);
! unsigned mifiread_getchannel(t_mifiread *mr);
! t_pd *mifiread_getowner(t_mifiread *mr);
! 
! t_mifiread *mifiread_new(t_pd *owner);
! void mifiread_setuserticks(t_mifiread *mr, double wholeticks);
! int mifiread_open(t_mifiread *mr, const char *filename,
! 		  const char *dirname, int complain);
! int mifiread_doit(t_mifiread *mr, t_mifireadhook hook, void *hookdata);
! void mifiread_close(t_mifiread *mr);
! void mifiread_free(t_mifiread *mr);
! 
! t_mifiwrite *mifiwrite_new(t_pd *owner);
! void mifiwrite_sethardticks(t_mifiwrite *mw, int beatticks);
! void mifiwrite_setuserticks(t_mifiwrite *mw, double wholeticks);
! void mifiwrite_setusertempo(t_mifiwrite *mw, double tickspersec);
! int mifiwrite_open(t_mifiwrite *mw, const char *filename,
! 		   const char *dirname, int ntracks, int complain);
! int mifiwrite_opentrack(t_mifiwrite *mw, char *trackname, int complain);
! int mifiwrite_textevent(t_mifiwrite *mw, double delay,
! 			unsigned type, char *text);
! int mifiwrite_channelevent(t_mifiwrite *mw, double delay, unsigned status,
! 			   unsigned channel, unsigned data1, unsigned data2);
! int mifiwrite_closetrack(t_mifiwrite *mw, double enddelay, int complain);
! void mifiwrite_close(t_mifiwrite *mw);
! void mifiwrite_free(t_mifiwrite *mw);
  
  #endif

Index: binport.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/binport.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** binport.c	12 May 2004 15:01:35 -0000	1.5
--- binport.c	8 Dec 2004 15:40:12 -0000	1.6
***************
*** 14,18 ****
  #define BINPORT_SYMGROW      64
  
! #ifndef BINPORT_STANDALONE
  /* load a max binary file into a Pd binbuf */
  
--- 14,18 ----
  #define BINPORT_SYMGROW      64
  
! #ifndef MIXED_STANDALONE
  /* load a max binary file into a Pd binbuf */
  
***************
*** 23,28 ****
  
  /* This is a standalone version of a ``max binary to binbuf'' module.
!    It uses certain Pd calls and structs, which are duplicated below.
!    LATER should be linked to the Pd API library. */
  
  #define BINPORT_VERBOSE
--- 23,31 ----
  
  /* This is a standalone version of a ``max binary to binbuf'' module.
!    It uses certain Pd calls and structs, which are duplicated in the
!    "standalone" module defined in shared/unstable.
!    LATER standalone binport should be linked to the Pd API library. */
! 
! #include "unstable/standalone.h"
  
  #define BINPORT_VERBOSE
***************
*** 30,42 ****
  #endif
  
  #include "binport.h"
  
  static void binport_error(char *fmt, ...)
  {
      va_list ap;
      va_start(ap, fmt);
!     fprintf(stderr, "ERROR (binport): ");
!     vfprintf(stderr, fmt, ap);
!     putc('\n', stderr);
      va_end(ap);
  }
--- 33,50 ----
  #endif
  
+ #include "common/lex.h"
  #include "binport.h"
  
  static void binport_error(char *fmt, ...)
  {
+     char buf[BINPORT_MAXSTRING];
      va_list ap;
      va_start(ap, fmt);
!     vsprintf(buf, fmt, ap);
! #ifdef MIXED_STANDALONE
!     fprintf(stderr, "ERROR (binport): %s\n", buf);
! #else
!     post("ERROR (binport): %s", buf);
! #endif
      va_end(ap);
  }
***************
*** 44,53 ****
  static void binport_warning(char *fmt, ...)
  {
! #if defined (BINPORT_STANDALONE) || defined(BINPORT_VERBOSE)
      va_list ap;
      va_start(ap, fmt);
!     fprintf(stderr, "warning (binport): ");
!     vfprintf(stderr, fmt, ap);
!     putc('\n', stderr);
      va_end(ap);
  #endif
--- 52,65 ----
  static void binport_warning(char *fmt, ...)
  {
! #if defined (MIXED_STANDALONE) || defined(BINPORT_VERBOSE)
!     char buf[BINPORT_MAXSTRING];
      va_list ap;
      va_start(ap, fmt);
!     vsprintf(buf, fmt, ap);
! #ifdef MIXED_STANDALONE
!     fprintf(stderr, "warning (binport): %s\n", buf);
! #else
!     post("warning (binport): %s", buf);
! #endif
      va_end(ap);
  #endif
***************
*** 56,64 ****
  static void binport_bug(char *fmt, ...)
  {
      va_list ap;
      va_start(ap, fmt);
!     fprintf(stderr, "BUG (binport): ");
!     vfprintf(stderr, fmt, ap);
!     putc('\n', stderr);
      va_end(ap);
  }
--- 68,80 ----
  static void binport_bug(char *fmt, ...)
  {
+     char buf[BINPORT_MAXSTRING];
      va_list ap;
      va_start(ap, fmt);
!     vsprintf(buf, fmt, ap);
! #ifdef MIXED_STANDALONE
!     fprintf(stderr, "BUG (binport): %s\n", buf);
! #else
!     bug("(binport) %s", buf);
! #endif
      va_end(ap);
  }
***************
*** 75,190 ****
  }
  
- #ifdef BINPORT_STANDALONE
- 
- typedef int t_int;
- typedef float t_float;
- 
- typedef struct _symbol
- {
-     char *s_name;
-     void *s_thing;
-     struct _symbol *s_next;
- } t_symbol;
- 
- typedef union word
- {
-     t_float w_float;
-     t_symbol *w_symbol;
-     int w_index;
- } t_word;
- 
- typedef enum
- {
-     A_NULL,
-     A_FLOAT,
-     A_SYMBOL,
-     A_POINTER,
-     A_SEMI,
-     A_COMMA,
-     A_DEFFLOAT,
-     A_DEFSYM,
-     A_DOLLAR, 
-     A_DOLLSYM,
-     A_GIMME,
-     A_CANT
- }  t_atomtype;
- 
- typedef struct _atom
- {
-     t_atomtype a_type;
-     union word a_w;
- } t_atom;
- 
- void *getbytes(size_t nbytes)
- {
-     void *ret;
-     if (nbytes < 1) nbytes = 1;
-     ret = (void *)calloc(nbytes, 1);
-     if (!ret)
- 	binport_error("getbytes() failed -- out of memory");
-     return (ret);
- }
- 
- void *resizebytes(void *old, size_t oldsize, size_t newsize)
- {
-     void *ret;
-     if (newsize < 1) newsize = 1;
-     if (oldsize < 1) oldsize = 1;
-     ret = (void *)realloc((char *)old, newsize);
-     if (newsize > oldsize && ret)
-     	memset(((char *)ret) + oldsize, 0, newsize - oldsize);
-     if (!ret)
-     	binport_error("resizebytes() failed -- out of memory");
-     return (ret);
- }
- 
- void freebytes(void *fatso, size_t nbytes)
- {
-     free(fatso);
- }
- 
- #define HASHSIZE 1024
- 
- static t_symbol *symhash[HASHSIZE];
- 
- t_symbol *dogensym(char *s, t_symbol *oldsym)
- {
-     t_symbol **sym1, *sym2;
-     unsigned int hash1 = 0,  hash2 = 0;
-     int length = 0;
-     char *s2 = s;
-     while (*s2)
-     {
- 	hash1 += *s2;
- 	hash2 += hash1;
- 	length++;
- 	s2++;
-     }
-     sym1 = symhash + (hash2 & (HASHSIZE-1));
-     while (sym2 = *sym1)
-     {
- 	if (!strcmp(sym2->s_name, s)) return(sym2);
- 	sym1 = &sym2->s_next;
-     }
-     if (oldsym) sym2 = oldsym;
-     else
-     {
-     	sym2 = (t_symbol *)getbytes(sizeof(*sym2));
-     	sym2->s_name = getbytes(length+1);
-     	sym2->s_next = 0;
-     	sym2->s_thing = 0;
-     	strcpy(sym2->s_name, s);
-     }
-     *sym1 = sym2;
-     return (sym2);
- }
- 
- t_symbol *gensym(char *s)
- {
-     return(dogensym(s, 0));
- }
- 
- #endif  /* end of Pd API */
- 
  enum {
      BINPORT_NULLTYPE,
--- 91,94 ----
***************
*** 500,503 ****
--- 404,408 ----
      t_symbol  **b_symtable;
      t_binpold  *b_old;
+     t_lex      *b_lex;
  } t_binport;
  
***************
*** 567,690 ****
  }
  
- /* single pass of binbuf_text(), int-preserving version */
- static int maxtext_nextatom(FILE *fp, t_atom *ap)
- {
-     char buf[BINPORT_MAXSTRING + 1], *bufp, *ebuf = buf + BINPORT_MAXSTRING;
-     int ready;
-     unsigned char ch;
-     ap->a_type = A_NULL;
-     while ((ready = binport_readbyte(fp, &ch)) &&
- 	   (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'));
-     if (!ready)
- 	return (0);
-     if (ch == ';')
- 	ap->a_type = A_SEMI;
-     else if (ch == ',')
- 	ap->a_type = A_COMMA;
-     else
-     {
- 	int floatstate = 0, slash = 0, lastslash = 0, firstslash = (ch == '\\');
- 	bufp = buf;
- 	do
- 	{
- 	    *bufp = ch;
- 	    lastslash = slash;
- 	    slash = (ch == '\\');
- 
- 	    if (floatstate >= 0)
- 	    {
- 		int digit = (ch >= '0' && ch <= '9'),
- 		    dot = (ch == '.'), minus = (ch == '-'),
- 		    plusminus = (minus || (ch == '+')),
- 		    expon = (ch == 'e' || ch == 'E');
- 		if (floatstate == 0)    /* beginning */
- 		{
- 		    if (minus) floatstate = 1;
- 		    else if (digit) floatstate = 2;
- 		    else if (dot) floatstate = 3;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 1)	/* got minus */
- 		{
- 		    if (digit) floatstate = 2;
- 		    else if (dot) floatstate = 3;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 2)	/* got digits */
- 		{
- 		    if (dot) floatstate = 4;
- 		    else if (expon) floatstate = 6;
- 		    else if (!digit) floatstate = -1;
- 		}
- 		else if (floatstate == 3)	/* got '.' without digits */
- 		{
- 		    if (digit) floatstate = 5;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 4)	/* got '.' after digits */
- 		{
- 		    if (digit) floatstate = 5;
- 		    else if (expon) floatstate = 6;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 5)	/* got digits after . */
- 		{
- 		    if (expon) floatstate = 6;
- 		    else if (!digit) floatstate = -1;
- 		}
- 		else if (floatstate == 6)	/* got 'e' */
- 		{
- 		    if (plusminus) floatstate = 7;
- 		    else if (digit) floatstate = 8;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 7)	/* got plus or minus */
- 		{
- 		    if (digit) floatstate = 8;
- 		    else floatstate = -1;
- 		}
- 		else if (floatstate == 8)	/* got digits */
- 		{
- 		    if (!digit) floatstate = -1;
- 		}
- 	    }
- 	    if (!slash) bufp++;
- 	}
- 	while ((ready = binport_readbyte(fp, &ch)) && bufp != ebuf
- 	       && (slash || (ch != ' ' && ch != '\n' && ch != '\r'
- 			     && ch != '\t' && ch != ',' && ch != ';')));
- 	if (ready && (ch == ',' || ch == ';'))
- 	    ungetc(ch, fp);
- 	*bufp = 0;
- #if 0
- 	fprintf(stderr, "buf %s\n", buf);
- #endif
- 	if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash)
- 	{
- 	    for (bufp = buf+2; *bufp; bufp++)
- 	    {
- 		if (*bufp < '0' || *bufp > '9')
- 		{
- 		    ap->a_type = A_DOLLSYM;
- 		    ap->a_w.w_symbol = gensym(buf+1);
- 		    break;
- 		}
- 	    }
- 	    if (ap->a_type == A_NULL)
- 	    {
- 		ap->a_type = A_DOLLAR;
- 		ap->a_w.w_index = atoi(buf+1);
- 	    }
- 	}
- 	else if (floatstate == 2)
- 	    binport_setint(ap, atoi(buf));
- 	else if (floatstate == 4 || floatstate == 5 || floatstate == 8)
- 	    binport_setfloat(ap, (float)atof(buf));
- 	else
- 	    binport_setsymbol(ap, gensym(buf));
-     }
-     return (1);
- }
- 
  static int binport_nextatom(t_binport *bp, t_atom *ap)
  {
--- 472,475 ----
***************
*** 693,698 ****
      char buf[64];
  
!     if (bp->b_ftype == BINPORT_MAXTEXT)
! 	return (maxtext_nextatom(bp->b_fp, ap));
      else if (bp->b_ftype == BINPORT_MAXOLD && bp->b_old)
  	return (binpold_nextatom(bp->b_old, ap));
--- 478,483 ----
      char buf[64];
  
!     if (bp->b_ftype == BINPORT_MAXTEXT && bp->b_lex)
! 	return (lex_nextatom(bp->b_lex, ap));
      else if (bp->b_ftype == BINPORT_MAXOLD && bp->b_old)
  	return (binpold_nextatom(bp->b_old, ap));
***************
*** 824,827 ****
--- 609,617 ----
  	binpold_free(bp->b_old);
      }
+     if (bp->b_lex)
+     {
+ 	bp->b_lex->l_fp = 0;
+ 	lex_free(bp->b_lex);
+     }
      freebytes(bp, sizeof(*bp));
  }
***************
*** 852,855 ****
--- 642,646 ----
  	    }
  	    bp->b_old = 0;
+ 	    bp->b_lex = 0;
  	}
  	else if (*ftypep != BINPORT_PDFILE)
***************
*** 867,916 ****
  }
  
- static void binport_atomstring(t_atom *ap, char *buf, int bufsize)
- {
-     char *sp, *bp, *ep;
-     switch(ap->a_type)
-     {
-     case A_SEMI:
- 	strcpy(buf, ";"); break;
-     case A_COMMA:
- 	strcpy(buf, ","); break;
-     case A_INT:
- 	sprintf(buf, "%d", ap->a_w.w_index); break;
-     case A_FLOAT:
- 	sprintf(buf, "%#f", ap->a_w.w_float);
- 	ep = buf + strlen(buf) - 1;
- 	while (ep > buf && *ep == '0') *ep-- = 0;
- 	break;
-     case A_SYMBOL:
-     	sp = ap->a_w.w_symbol->s_name;
- 	bp = buf;
- 	ep = buf + (bufsize-5);
- 	while (bp < ep && *sp)
- 	{
- 	    if (*sp == ';' || *sp == ',' || *sp == '\\' ||
- 		(*sp == '$' && bp == buf && sp[1] >= '0' && sp[1] <= '9'))
- 		*bp++ = '\\';
- 	    if ((unsigned char)*sp < 127)
- 		*bp++ = *sp++;
- 	    else
- 		/* FIXME this is temporary -- codepage horror */
- 		sprintf(bp, "\\%.3o", (unsigned char)*sp++), bp += 4;
- 	}
- 	if (*sp) *bp++ = '*';
- 	*bp = 0;
- 	break;
-     case A_DOLLAR:
-     	sprintf(buf, "$%d", ap->a_w.w_index);
-     	break;
-     case A_DOLLSYM:
-     	sprintf(buf, "$%s", ap->a_w.w_symbol->s_name);
-     	break;
-     default:
-     	binport_bug("bad atom type");
- 	strcpy(buf, "???");
-     }
- }
- 
  static void binport_print(t_binport *bp, FILE *fp)
  {
--- 658,661 ----
***************
*** 930,934 ****
  	{
  	    if (cnt++) fputc(' ', fp);
! 	    binport_atomstring(&at, buf, BINPORT_MAXSTRING);
  	    fputs(buf, fp);
  	}
--- 675,679 ----
  	{
  	    if (cnt++) fputc(' ', fp);
! 	    lex_atomstring(&at, buf, BINPORT_MAXSTRING, A_INT);
  	    fputs(buf, fp);
  	}
***************
*** 936,940 ****
  }
  
! #ifndef BINPORT_STANDALONE
  
  static int binport_tobinbuf(t_binport *bp, t_binbuf *bb)
--- 681,685 ----
  }
  
! #ifndef MIXED_STANDALONE
  
  static int binport_tobinbuf(t_binport *bp, t_binbuf *bb)
***************
*** 972,981 ****
  	    {
  		t_atom at;
! 		while (binport_nextatom(bp, &at))
! 		    if (at.a_type == A_SEMI)
! 			break;
! 		binbuf_addv(bb, "ss;", gensym("max"), gensym("v2"));
! 		result = (binport_tobinbuf(bp, bb)
! 			  ? BINPORT_OK : BINPORT_CORRUPT);
  	    }
  	    else if (ftype == BINPORT_MAXOLD)
--- 717,730 ----
  	    {
  		t_atom at;
! 		if (bp->b_lex = lex_new(fp, A_INT))
! 		{
! 		    while (binport_nextatom(bp, &at))
! 			if (at.a_type == A_SEMI)
! 			    break;
! 		    binbuf_addv(bb, "ss;", gensym("max"), gensym("v2"));
! 		    result = (binport_tobinbuf(bp, bb)
! 			      ? BINPORT_OK : BINPORT_CORRUPT);
! 		}
! 		else result = BINPORT_FAILED;
  	    }
  	    else if (ftype == BINPORT_MAXOLD)
***************
*** 1037,1041 ****
  	    {
  		if (cnt++) fputc(' ', fp);
! 		binport_atomstring(ap, buf, BINPORT_MAXSTRING);
  		fputs(buf, fp);
  	    }
--- 786,790 ----
  	    {
  		if (cnt++) fputc(' ', fp);
! 		lex_atomstring(ap, buf, BINPORT_MAXSTRING, A_INT);
  		fputs(buf, fp);
  	    }

Index: loud.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/loud.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** loud.c	17 Apr 2004 17:45:28 -0000	1.3
--- loud.c	8 Dec 2004 15:40:12 -0000	1.4
***************
*** 10,30 ****
  #include "common/loud.h"
  
! #define LOUD_ERROR_DEFAULT  "error (miXed): "
  
! /* LATER move it somewhere else */
! t_symbol *loud_floatsym(void)
  {
!     static t_symbol *s = 0;
!     return (s ? s : (s = gensym("noninteger float")));
  }
  
! /* LATER move it somewhere else */
! char *loud_symbolname(t_symbol *s, char *nullname)
  {
!     return (s && s != &s_ ? s->s_name : nullname);
  }
  
! /* LATER move it somewhere else */
! int loud_matchignorecase(char *test, char *pattern)
  {
      char ct, cp;
--- 10,99 ----
  #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)
  {
      char ct, cp;
***************
*** 38,42 ****
  }
  
! /* LATER move it somewhere else */
  char *loud_ordinal(int n)
  {
--- 107,124 ----
  }
  
! struct _loudcontext
! {
!     t_pd      *lc_caller;    /* an object reporting trouble */
!     char      *lc_callername;
!     int        lc_cnsize;
!     /* during object creation, use the following: */
!     t_symbol  *lc_selector;  /* creation message selector (class name) */
!     int        lc_ac;        /* creation message arguments */
!     t_atom    *lc_av;        /* void out of creation context */
!     int        lc_andindent;
! };
! 
! #define LOUD_ERROR_DEFAULT  "error (miXed):"
! 
  char *loud_ordinal(int n)
  {
***************
*** 61,79 ****
  void loud_error(t_pd *x, char *fmt, ...)
  {
      va_list ap;
      va_start(ap, fmt);
      if (x)
      {
! 	char buf[MAXPDSTRING];
! 	fprintf(stderr, "%s's ", class_getname(*x));
! 	vsprintf(buf, fmt, ap);
  	pd_error(x, buf);
      }
!     else
!     {
! 	fputs(LOUD_ERROR_DEFAULT, stderr);
! 	vfprintf(stderr, fmt, ap);
! 	putc('\n', stderr);
!     }
      va_end(ap);
  }
--- 143,156 ----
  void loud_error(t_pd *x, char *fmt, ...)
  {
+     char buf[MAXPDSTRING];
      va_list ap;
      va_start(ap, fmt);
+     vsprintf(buf, fmt, ap);
      if (x)
      {
! 	startpost("%s's ", class_getname(*x));
  	pd_error(x, buf);
      }
!     else post("%s %s", LOUD_ERROR_DEFAULT, buf);
      va_end(ap);
  }
***************
*** 81,90 ****
  void loud_errand(t_pd *x, char *fmt, ...)
  {
      va_list ap;
      va_start(ap, fmt);
!     fprintf(stderr, "%*s", (int)(x ? strlen(class_getname(*x)) + 10
! 				 : strlen(LOUD_ERROR_DEFAULT)), "");
!     vfprintf(stderr, fmt, ap);
!     putc('\n', stderr);
      va_end(ap);
  }
--- 158,167 ----
  void loud_errand(t_pd *x, char *fmt, ...)
  {
+     char buf[MAXPDSTRING];
      va_list ap;
      va_start(ap, fmt);
!     vsprintf(buf, fmt, ap);
!     post("%*s%s", (int)(x ? strlen(class_getname(*x)) + 10
! 			: strlen(LOUD_ERROR_DEFAULT) + 1), "", buf);
      va_end(ap);
  }
***************
*** 114,122 ****
      else
      {
  	if (mess == &s_float)
! 	    loud_nomethod(x, loud_floatsym());
  	else if (mess)
  	    loud_error(x, "\"%s\" argument invalid for message \"%s\"",
! 		       loud_floatsym()->s_name, mess->s_name);
  	return (0);
      }
--- 191,202 ----
      else
      {
+ 	static t_symbol *floatsym = 0;
+ 	if (!floatsym)
+ 	    floatsym = gensym("noninteger float");
  	if (mess == &s_float)
! 	    loud_nomethod(x, floatsym);
  	else if (mess)
  	    loud_error(x, "\"%s\" argument invalid for message \"%s\"",
! 		       floatsym->s_name, mess->s_name);
  	return (0);
      }
***************
*** 130,140 ****
  void loud_warning(t_pd *x, char *who, char *fmt, ...)
  {
      va_list ap;
      va_start(ap, fmt);
!     fprintf(stderr, "warning (%s): ",
! 	    (x ? class_getname(*x) : (who ? who : "miXed")));
!     vfprintf(stderr, fmt, ap);
      va_end(ap);
-     putc('\n', stderr);
  }
  
--- 210,220 ----
  void loud_warning(t_pd *x, char *who, char *fmt, ...)
  {
+     char buf[MAXPDSTRING];
      va_list ap;
      va_start(ap, fmt);
!     vsprintf(buf, fmt, ap);
!     post("warning (%s): %s",
! 	 (x ? class_getname(*x) : (who ? who : "miXed")), buf);
      va_end(ap);
  }
  
***************
*** 149,159 ****
  void loud_incompatible(t_class *c, char *fmt, ...)
  {
!     va_list ap;
!     va_start(ap, fmt);
!     fprintf(stderr, "'%s' class incompatibility warning:\n\t",
! 	    class_getname(c));
!     vfprintf(stderr, fmt, ap);
!     va_end(ap);
!     putc('\n', stderr);
  }
  
--- 229,242 ----
  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);
!     }
  }
  
***************
*** 223,224 ****
--- 306,438 ----
      return (result);
  }
+ 
+ void loudx_error(t_loudcontext *lc, char *fmt, ...)
+ {
+     char buf[MAXPDSTRING];
+     va_list ap;
+     va_start(ap, fmt);
+     vsprintf(buf, fmt, ap);
+     if (lc->lc_caller)
+     {
+ 	startpost("%s's ", (lc->lc_callername ?
+ 			    lc->lc_callername : class_getname(*lc->lc_caller)));
+ 	pd_error(lc->lc_caller, buf);
+     }
+     else
+     {
+ 	if (lc->lc_callername)
+ 	    post("error (%s): %s", lc->lc_callername, buf);
+ 	else if (lc->lc_selector)
+ 	    post("error (%s): %s", lc->lc_selector->s_name, buf);
+ 	else
+ 	    post("%s %s", LOUD_ERROR_DEFAULT, buf);
+     }
+     va_end(ap);
+ }
+ 
+ void loudx_errand(t_loudcontext *lc, char *fmt, ...)
+ {
+     char buf[MAXPDSTRING];
+     va_list ap;
+     va_start(ap, fmt);
+     vsprintf(buf, fmt, ap);
+     post("%*s%s", lc->lc_andindent, "", buf);
+     va_end(ap);
+ }
+ 
+ void loudx_nomethod(t_loudcontext *lc, t_symbol *s)
+ {
+     loudx_error(lc, "doesn't understand \"%s\"", s->s_name);
+ }
+ 
+ void loudx_messarg(t_loudcontext *lc, t_symbol *s)
+ {
+     loudx_error(lc, "bad arguments for message \"%s\"", s->s_name);
+ }
+ 
+ void loudx_warning(t_loudcontext *lc, char *fmt, ...)
+ {
+     char buf[MAXPDSTRING];
+     va_list ap;
+     va_start(ap, fmt);
+     vsprintf(buf, fmt, ap);
+     if (lc->lc_callername)
+ 	post("warning (%s): %s", lc->lc_callername, buf);
+     else if (lc->lc_selector)
+ 	post("warning (%s): %s", lc->lc_selector->s_name, buf);
+     else
+ 	post("warning (miXed): %s", buf);
+     va_end(ap);
+ }
+ 
+ void loudx_setcontext(t_loudcontext *lc, t_pd *caller, char *callername,
+ 		      t_symbol *s, int ac, t_atom *av)
+ {
+     if (lc->lc_callername)
+ 	freebytes(lc->lc_callername, lc->lc_cnsize);
+     lc->lc_caller = caller;
+     if (callername)
+     {
+ 	lc->lc_cnsize = strlen(callername) + 1;
+ 	lc->lc_callername = getbytes(lc->lc_cnsize);
+ 	strcpy(lc->lc_callername, callername);
+     }
+     else
+     {
+ 	lc->lc_callername = 0;
+ 	lc->lc_cnsize = 0;
+     }
+     lc->lc_selector = s;
+     lc->lc_ac = ac;
+     lc->lc_av = av;
+     if (callername)
+ 	lc->lc_andindent = lc->lc_cnsize + 9;
+     else if (caller)
+ 	lc->lc_andindent = strlen(class_getname(*caller)) + 10;
+     else if (s)
+ 	lc->lc_andindent = strlen(s->s_name) + 10;
+     else
+ 	lc->lc_andindent = strlen(LOUD_ERROR_DEFAULT) + 1;
+ }
+ 
+ /* must call before going out of creation context */
+ void loudx_setcaller(t_loudcontext *lc, t_pd *caller, char *callerfmt, ...)
+ {
+     va_list ap;
+     va_start(ap, callerfmt);
+     if (callerfmt)
+     {
+ 	char buf[MAXPDSTRING];
+ 	vsprintf(buf, callerfmt, ap);
+ 	loudx_setcontext(lc, caller, buf, lc->lc_selector, 0, 0);
+     }
+     else loudx_setcontext(lc, caller, 0, lc->lc_selector, 0, 0);
+     va_end(ap);
+ }
+ 
+ t_symbol *loudx_getselector(t_loudcontext *lc)
+ {
+     return (lc->lc_selector);
+ }
+ 
+ t_atom *loudx_getarguments(t_loudcontext *lc, int *acp)
+ {
+     *acp = lc->lc_ac;
+     return (lc->lc_av);
+ }
+ 
+ void loudx_freecontext(t_loudcontext *lc)
+ {
+     if (lc->lc_callername)
+ 	freebytes(lc->lc_callername, lc->lc_cnsize);
+     freebytes(lc, sizeof(*lc));
+ }
+ 
+ t_loudcontext *loudx_newcontext(t_pd *caller, char *callername,
+ 				t_symbol *s, int ac, t_atom *av)
+ {
+     t_loudcontext *lc = getbytes(sizeof(*lc));
+     lc->lc_callername = 0;
+     loudx_setcontext(lc, caller, callername, s, ac, av);
+     return (lc);
+ }

Index: Makefile.sources
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/Makefile.sources,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.sources	5 Nov 2003 14:08:23 -0000	1.3
--- Makefile.sources	8 Dec 2004 15:40:12 -0000	1.4
***************
*** 1,12 ****
  OTHER_SOURCES = \
- bifi.c \
  binport.c \
  dict.c \
  grow.c \
  loud.c \
  mifi.c \
  port.c \
  props.c \
  rand.c \
- sq.c \
  vefl.c
--- 1,14 ----
  OTHER_SOURCES = \
  binport.c \
+ clc.c \
  dict.c \
+ fi.c \
  grow.c \
+ lex.c \
  loud.c \
  mifi.c \
  port.c \
  props.c \
+ qtree.c \
  rand.c \
  vefl.c

Index: port.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** port.c	12 May 2004 15:01:35 -0000	1.13
--- port.c	8 Dec 2004 15:40:12 -0000	1.14
***************
*** 716,721 ****
  	    t_symbol *s = x->x_inmess[i].a_w.w_symbol;
  	    if (s->s_name[1])
  		x->x_inmess[i].a_w.w_symbol = gensym("s");
! 	    else switch (*s->s_name) {
  	    case 'b': case 'f': case 's': case 'l':
  		break;
--- 716,727 ----
  	    t_symbol *s = x->x_inmess[i].a_w.w_symbol;
  	    if (s->s_name[1])
+ 	    {
+ 		loud_warning(0, "import",
+ 			     "%s's argument '%s' bashed to 's'",
+ 			     port_getsymbol(x, 6)->s_name, s->s_name);
  		x->x_inmess[i].a_w.w_symbol = gensym("s");
! 	    }
! 	    else switch (*s->s_name)
! 	    {
  	    case 'b': case 'f': case 's': case 'l':
  		break;
***************
*** 1136,1140 ****
  	{
  	    if (slot->s_symbol == insym
! 		|| (inname && loud_matchignorecase(inname, slot->s_name)))
  	    {
  		if (slot->s_subtree)
--- 1142,1146 ----
  	{
  	    if (slot->s_symbol == insym
! 		|| (inname && shared_matchignorecase(inname, slot->s_name)))
  	    {
  		if (slot->s_subtree)

Index: loud.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/loud.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** loud.h	17 Apr 2004 17:45:28 -0000	1.3
--- loud.h	8 Dec 2004 15:40:12 -0000	1.4
***************
*** 1,3 ****
! /* Copyright (c) 2002-2003 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-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.  */
***************
*** 11,17 ****
  enum { LOUD_ARGOK, LOUD_ARGUNDER, LOUD_ARGOVER, LOUD_ARGTYPE, LOUD_ARGMISSING };
  
! t_symbol *loud_floatsym(void);
! char *loud_symbolname(t_symbol *s, char *nullname);
! int loud_matchignorecase(char *test, char *pattern);
  char *loud_ordinal(int n);
  void loud_error(t_pd *x, char *fmt, ...);
--- 11,24 ----
  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);
  void loud_error(t_pd *x, char *fmt, ...);
***************
*** 30,32 ****
--- 37,53 ----
  		  int underaction, int overaction, char *what);
  
+ void loudx_error(t_loudcontext *lc, char *fmt, ...);
+ void loudx_errand(t_loudcontext *lc, char *fmt, ...);
+ void loudx_nomethod(t_loudcontext *lc, t_symbol *s);
+ void loudx_messarg(t_loudcontext *lc, t_symbol *s);
+ void loudx_warning(t_loudcontext *lc, char *fmt, ...);
+ void loudx_setcontext(t_loudcontext *lc, t_pd *caller, char *callername,
+ 		      t_symbol *s, int ac, t_atom *av);
+ void loudx_setcaller(t_loudcontext *lc, t_pd *caller, char *callerfmt, ...);
+ t_symbol *loudx_getselector(t_loudcontext *lc);
+ t_atom *loudx_getarguments(t_loudcontext *lc, int *acp);
+ void loudx_freecontext(t_loudcontext *lc);
+ t_loudcontext *loudx_newcontext(t_pd *caller, char *callername,
+ 				t_symbol *s, int ac, t_atom *av);
+ 
  #endif

Index: binport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/binport.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** binport.h	17 Apr 2004 17:45:28 -0000	1.3
--- binport.h	8 Dec 2004 15:40:12 -0000	1.4
***************
*** 9,13 ****
         BINPORT_INVALID, BINPORT_CORRUPT, BINPORT_FAILED };
  
! #ifndef BINPORT_STANDALONE
  int binport_read(t_binbuf *bb, char *filename, char *dirname);
  void binport_write(t_binbuf *bb, char *filename, char *dirname);
--- 9,13 ----
         BINPORT_INVALID, BINPORT_CORRUPT, BINPORT_FAILED };
  
! #ifndef MIXED_STANDALONE
  int binport_read(t_binbuf *bb, char *filename, char *dirname);
  void binport_write(t_binbuf *bb, char *filename, char *dirname);

Index: mifi.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/mifi.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** mifi.c	14 Aug 2003 14:26:06 -0000	1.2
--- mifi.c	8 Dec 2004 15:40:12 -0000	1.3
***************
*** 1,8 ****
! /* Copyright (c) 2001-2003 krzYszcz and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
  
- /* reading/writing midifiles, a prototype version */
- 
  #ifdef NT
  #include <io.h>
--- 1,6 ----
! /* Copyright (c) 2004 krzYszcz and others.
[...2304 lines suppressed...]
+ void mifiwrite_free(t_mifiwrite *mw)
+ {
+     mifiwrite_close(mw);
+     if (mw->mw_event.e_data != mw->mw_event.e_dataini)
+ 	freebytes(mw->mw_event.e_data, mw->mw_event.e_datasize);
+     freebytes(mw, sizeof(*mw));
+ }
+ 
+ t_mifiwrite *mifiwrite_new(t_pd *owner)
+ {
+     t_mifiwrite *mw = getbytes(sizeof(*mw));
+     mifi_initialize();
+     mw->mw_owner = owner;
+     mw->mw_ntracks = 0;
+     mw->mw_tempo = MIFIHARD_DEFTEMPO;
+     mifievent_initialize(&mw->mw_event, MIFIEVENT_NALLOC);
+     mifiwrite_resetticks(mw);
+     mifiwrite_reset(mw);
+     return (mw);
+ }

Index: dict.c
===================================================================
RCS file: /cvsroot/pure-data/externals/miXed/shared/common/dict.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dict.c	26 Sep 2003 07:29:14 -0000	1.1
--- dict.c	8 Dec 2004 15:40:12 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (c) 1997-2003 Miller Puckette, 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) 1997-2004 Miller Puckette, krzYszcz, and others.
   * For information on usage and redistribution, and for a DISCLAIMER OF ALL
   * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
***************
*** 217,247 ****
  }
  
! /* adapted pd_findbyclass() from m_pd.c */
! t_pd *dict_value(t_dict *x, t_symbol *s)
  {
!     if (!s->s_thing) return (0);
!     if (*s->s_thing == x->d_bindlist_class)
      {
! 	t_pd *x = 0;
!     	t_dict_bindelem *e;
!     	int warned = 0;
! 	for (e = ((t_dict_bindlist *)s->s_thing)->b_list; e; e = e->e_next)
!     	{
!     	    if (x && !warned)
!     	    {
!     	    	post("warning: %s: multiply defined", s->s_name);
!     	    	warned = 1;
!     	    }
!     	    x = e->e_who;
!     	}
! 	return (x);
      }
!     return (s->s_thing);
  }
  
  t_pd *dict_xvalue(t_dict *x, t_symbol *s)
  {
      return (s && s != &s_ ? dict_value(x, dict_key(x, s->s_name)) : 0);
  }
  
  int dict_forall(t_dict *x, t_symbol *s, t_dict_hook hook, void *hookarg)
--- 217,266 ----
  }
  
! t_pd *dict_firstvalue(t_dict *dict, t_symbol *s, void **nextp)
  {
!     if (s->s_thing)
      {
! 	if (*s->s_thing == dict->d_bindlist_class)
! 	{
! 	    t_dict_bindelem *e = ((t_dict_bindlist *)s->s_thing)->b_list;
! 	    if (e)
! 	    {
! 		if (nextp)
! 		    *nextp = e->e_next;
! 		return (e->e_who);
! 	    }
! 	    else return (0);
! 	}
! 	else
! 	{
! 	    if (nextp)
! 		*nextp = 0;
! 	    return (s->s_thing);
! 	}
      }
!     else return (0);
! }
! 
! t_pd *dict_nextvalue(t_dict *dict, t_symbol *s, void **nextp)
! {
!     if (s->s_thing)
!     {
! 	if (*s->s_thing == dict->d_bindlist_class && *nextp)
! 	{
! 	    t_dict_bindelem *e = (t_dict_bindelem *)*nextp;
! 	    *nextp = e->e_next;
! 	    return (e->e_who);
! 	}
!     }
!     else bug("dict_nextvalue");
!     return (0);
  }
  
+ #if 0
  t_pd *dict_xvalue(t_dict *x, t_symbol *s)
  {
      return (s && s != &s_ ? dict_value(x, dict_key(x, s->s_name)) : 0);
  }
+ #endif
  
  int dict_forall(t_dict *x, t_symbol *s, t_dict_hook hook, void *hookarg)





More information about the Pd-cvs mailing list