aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.common2
-rw-r--r--ViCious/cyclone/sources2
-rw-r--r--cyclone/Makefile.sources2
-rw-r--r--cyclone/hammer/Decode.c10
-rw-r--r--cyclone/hammer/bangbang.c10
-rw-r--r--cyclone/hammer/cycle.c10
-rw-r--r--cyclone/hammer/gate.c10
-rw-r--r--cyclone/hammer/maximum.c5
-rw-r--r--cyclone/hammer/minimum.c5
-rw-r--r--cyclone/hammer/mtr.c335
-rw-r--r--cyclone/hammer/past.c10
-rw-r--r--cyclone/hammer/switch.c10
-rw-r--r--cyclone/hammer/urn.c14
-rw-r--r--cyclone/sickle/Makefile.sources2
-rw-r--r--cyclone/sickle/allsickles.c4
-rw-r--r--cyclone/sickle/maximum.c50
-rw-r--r--cyclone/sickle/minimum.c50
-rw-r--r--cyclone/sickle/pong.c4
18 files changed, 399 insertions, 136 deletions
diff --git a/Makefile.common b/Makefile.common
index 7023540..25ebd88 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -14,7 +14,7 @@ TILDE = ~
include Makefile.sources
include Makefile.objects
-CC = gcc
+CC = gcc-2.95
default: define_build all
diff --git a/ViCious/cyclone/sources b/ViCious/cyclone/sources
index 633afac..92e5f84 100644
--- a/ViCious/cyclone/sources
+++ b/ViCious/cyclone/sources
@@ -159,6 +159,8 @@ ALL_SICKLES = \
sickle\linedrive.c \
sickle\log.c \
sickle\lookup.c \
+ sickle\maximum.c \
+ sickle\minimum.c \
sickle\minmax.c \
sickle\peakamp.c \
sickle\peek.c \
diff --git a/cyclone/Makefile.sources b/cyclone/Makefile.sources
index 8ab5893..6b7afcc 100644
--- a/cyclone/Makefile.sources
+++ b/cyclone/Makefile.sources
@@ -133,6 +133,8 @@ sickle/deltaclip.c \
sickle/edge.c \
sickle/kink.c \
sickle/log.c \
+sickle/maximum.c \
+sickle/minimum.c \
sickle/minmax.c \
sickle/peakamp.c \
sickle/phasewrap.c \
diff --git a/cyclone/hammer/Decode.c b/cyclone/hammer/Decode.c
index 8317d7e..4dee7e0 100644
--- a/cyclone/hammer/Decode.c
+++ b/cyclone/hammer/Decode.c
@@ -8,8 +8,8 @@
#include "m_pd.h"
#include "common/loud.h"
-#define DECODE_MAXOUTS 8 /* CHECKED (does it make any sense?) */
-#define DECODE_DEFOUTS 1
+#define DECODE_C74MAXOUTS 8 /* CHECKED (does it make any sense?) */
+#define DECODE_DEFOUTS 1
typedef struct _Decode
{
@@ -19,7 +19,7 @@ typedef struct _Decode
int x_allon; /* submaster switch */
int x_alloff; /* master switch */
t_outlet **x_outs;
- t_outlet *x_outbuf[DECODE_MAXOUTS];
+ t_outlet *x_outbuf[DECODE_C74MAXOUTS];
} t_Decode;
static t_class *Decode_class;
@@ -76,9 +76,9 @@ static void *Decode_new(t_floatarg val)
t_outlet **outs;
if (nouts < 1)
nouts = DECODE_DEFOUTS;
- if (nouts > DECODE_MAXOUTS)
+ if (nouts > DECODE_C74MAXOUTS)
{
- loud_incompatible_max(Decode_class, DECODE_MAXOUTS, "outlets");
+ loud_incompatible_max(Decode_class, DECODE_C74MAXOUTS, "outlets");
if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs))))
return (0);
}
diff --git a/cyclone/hammer/bangbang.c b/cyclone/hammer/bangbang.c
index bebd26e..695a558 100644
--- a/cyclone/hammer/bangbang.c
+++ b/cyclone/hammer/bangbang.c
@@ -8,9 +8,9 @@
#include "m_pd.h"
#include "common/loud.h"
-#define BANGBANG_MINOUTS 1
-#define BANGBANG_MAXOUTS 40 /* CHECKED (just clipped without warning) */
-#define BANGBANG_DEFOUTS 2
+#define BANGBANG_MINOUTS 1
+#define BANGBANG_C74MAXOUTS 40 /* CHECKED (just clipped without warning) */
+#define BANGBANG_DEFOUTS 2
typedef struct _bangbang
{
@@ -46,8 +46,8 @@ static void *bangbang_new(t_floatarg val)
t_outlet **outs;
if (nouts < BANGBANG_MINOUTS)
nouts = BANGBANG_DEFOUTS;
- if (nouts > BANGBANG_MAXOUTS)
- loud_incompatible_max(bangbang_class, BANGBANG_MAXOUTS, "outlets");
+ if (nouts > BANGBANG_C74MAXOUTS)
+ loud_incompatible_max(bangbang_class, BANGBANG_C74MAXOUTS, "outlets");
if (nouts > BANGBANG_DEFOUTS)
{
if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs))))
diff --git a/cyclone/hammer/cycle.c b/cyclone/hammer/cycle.c
index faffc01..2e6dbd0 100644
--- a/cyclone/hammer/cycle.c
+++ b/cyclone/hammer/cycle.c
@@ -10,9 +10,9 @@
//#define CYCLE_USEEVENTNO
-#define CYCLE_MINOUTS 1
-#define CYCLE_MAXOUTS 100 /* CHECKED */
-#define CYCLE_DEFOUTS 1
+#define CYCLE_MINOUTS 1
+#define CYCLE_C74MAXOUTS 100 /* CHECKED */
+#define CYCLE_DEFOUTS 1
typedef struct _cycle
{
@@ -117,9 +117,9 @@ static void *cycle_new(t_floatarg f1, t_floatarg f2)
t_outlet **outs;
if (nouts < CYCLE_MINOUTS)
nouts = CYCLE_DEFOUTS;
- if (nouts > CYCLE_MAXOUTS)
+ if (nouts > CYCLE_C74MAXOUTS)
{
- loud_incompatible_max(cycle_class, CYCLE_MAXOUTS, "outlets");
+ loud_incompatible_max(cycle_class, CYCLE_C74MAXOUTS, "outlets");
/* CHECKED: max clips with an error:
``perhaps you were trying to make an oscillator?'' */
}
diff --git a/cyclone/hammer/gate.c b/cyclone/hammer/gate.c
index 2dbae57..19035a5 100644
--- a/cyclone/hammer/gate.c
+++ b/cyclone/hammer/gate.c
@@ -5,9 +5,9 @@
#include "m_pd.h"
#include "common/loud.h"
-#define GATE_MINOUTS 1
-#define GATE_MAXOUTS 100
-#define GATE_DEFOUTS 1
+#define GATE_MINOUTS 1
+#define GATE_C74MAXOUTS 100
+#define GATE_DEFOUTS 1
typedef struct _gate
{
@@ -99,8 +99,8 @@ static void *gate_new(t_floatarg f1, t_floatarg f2)
t_pd *proxy;
if (nouts < GATE_MINOUTS)
nouts = GATE_DEFOUTS;
- if (nouts > GATE_MAXOUTS)
- loud_incompatible_max(gate_class, GATE_MAXOUTS, "outlets");
+ if (nouts > GATE_C74MAXOUTS)
+ loud_incompatible_max(gate_class, GATE_C74MAXOUTS, "outlets");
nouts++; /* for convenience (the cost is one pointer) */
if (!(outs = (t_outlet **)getbytes(nouts * sizeof(*outs))))
return (0);
diff --git a/cyclone/hammer/maximum.c b/cyclone/hammer/maximum.c
index 038d8f1..f7f01f1 100644
--- a/cyclone/hammer/maximum.c
+++ b/cyclone/hammer/maximum.c
@@ -5,6 +5,8 @@
#include "m_pd.h"
#include "common/loud.h"
+#define MAXIMUM_C74MAXITEMS 256
+
typedef struct _maximum
{
t_object x_ob;
@@ -27,7 +29,8 @@ static void maximum_float(t_maximum *x, t_float f)
static void maximum_list(t_maximum *x, t_symbol *s, int ac, t_atom *av)
{
- if (ac > 256) loud_incompatible_max(*(t_pd *)x, 256, "items");
+ if (ac > MAXIMUM_C74MAXITEMS)
+ loud_incompatible_max(*(t_pd *)x, MAXIMUM_C74MAXITEMS, "items");
while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME (a warning?) */
if (ac)
{
diff --git a/cyclone/hammer/minimum.c b/cyclone/hammer/minimum.c
index 466b6f8..415235d 100644
--- a/cyclone/hammer/minimum.c
+++ b/cyclone/hammer/minimum.c
@@ -5,6 +5,8 @@
#include "m_pd.h"
#include "common/loud.h"
+#define MINIMUM_C74MAXITEMS 256
+
typedef struct _minimum
{
t_object x_ob;
@@ -27,7 +29,8 @@ static void minimum_float(t_minimum *x, t_float f)
static void minimum_list(t_minimum *x, t_symbol *s, int ac, t_atom *av)
{
- if (ac > 256) loud_incompatible_max(*(t_pd *)x, 256, "items");
+ if (ac > MINIMUM_C74MAXITEMS)
+ loud_incompatible_max(*(t_pd *)x, MINIMUM_C74MAXITEMS, "items");
while (ac && av->a_type != A_FLOAT) ac--, av++; /* CHECKME (a warning?) */
if (ac)
{
diff --git a/cyclone/hammer/mtr.c b/cyclone/hammer/mtr.c
index c1fe022..edc5e20 100644
--- a/cyclone/hammer/mtr.c
+++ b/cyclone/hammer/mtr.c
@@ -1,7 +1,10 @@
-/* Copyright (c) 2002-2003 krzYszcz and others.
+/* Copyright (c) 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. */
+/* CHECKME undocumented: readbinbuf, writebinbuf (a clipboard-like thing?) */
+
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "m_pd.h"
@@ -9,7 +12,11 @@
#include "common/loud.h"
#include "hammer/file.h"
-//#define MTR_DEBUG
+#define MTR_DEBUG
+
+#define MTR_C74MAXTRACKS 32
+#define MTR_FILEBUFSIZE 4096
+#define MTR_FILEMAXCOLUMNS 78
enum { MTR_STEPMODE, MTR_RECMODE, MTR_PLAYMODE };
@@ -80,8 +87,10 @@ static void mtrack_donext(t_mtrack *tp)
tp->tr_clockdelay = delta * tp->tr_tempo);
tp->tr_prevtime = clock_getlogicaltime();
}
+ else if (ixmess < 2) /* LATER rethink */
+ continue; /* CHECKED first delta skipped */
else
- { /* CHECKME first step */
+ { /* CHECKED this is not blocked with the muted flag */
t_atom at[2];
SETFLOAT(&at[0], tp->tr_id);
SETFLOAT(&at[1], delta);
@@ -121,9 +130,21 @@ static void mtrack_donext(t_mtrack *tp)
}
}
endoftrack:
+ if (tp->tr_mode == MTR_PLAYMODE)
+ tp->tr_ixnext = 0; /* CHECKED ready to go in step mode after play */
+ else
+ {
+ if (tp->tr_ixnext > 0)
+ {
+ t_atom at[2];
+ SETFLOAT(&at[0], tp->tr_id);
+ SETFLOAT(&at[1], -1.); /* CHECKED eot marker */
+ outlet_list(tp->tr_mainout, 0, 2, at);
+ }
+ tp->tr_ixnext = -1; /* CHECKED no loop-over */
+ }
tp->tr_atdelta = 0;
- tp->tr_ixnext = -1;
- tp->tr_prevtime = 0;
+ tp->tr_prevtime = 0.;
tp->tr_mode = MTR_STEPMODE;
}
@@ -131,7 +152,7 @@ static void mtrack_tick(t_mtrack *tp)
{
if (tp->tr_mode == MTR_PLAYMODE)
{
- tp->tr_prevtime = 0;
+ tp->tr_prevtime = 0.;
mtrack_donext(tp);
}
}
@@ -141,7 +162,7 @@ static void mtrack_setmode(t_mtrack *tp, int newmode)
if (tp->tr_mode == MTR_PLAYMODE)
{
clock_unset(tp->tr_clock);
- tp->tr_ixnext = -1;
+ tp->tr_ixnext = 0;
}
switch (tp->tr_mode = newmode)
{
@@ -154,7 +175,7 @@ static void mtrack_setmode(t_mtrack *tp, int newmode)
case MTR_PLAYMODE:
tp->tr_atdelta = 0;
tp->tr_ixnext = 0;
- tp->tr_prevtime = 0;
+ tp->tr_prevtime = 0.;
mtrack_donext(tp);
break;
default:
@@ -164,7 +185,7 @@ static void mtrack_setmode(t_mtrack *tp, int newmode)
static void mtrack_doadd(t_mtrack *tp, int ac, t_atom *av)
{
- if (tp->tr_prevtime > 0)
+ if (tp->tr_prevtime > 0.)
{
t_binbuf *bb = tp->tr_binbuf;
t_atom at;
@@ -234,13 +255,13 @@ static void mtrack_rewind(t_mtrack *tp)
}
}
-/* CHECKME step mode */
+/* CHECKED step and play mode */
static void mtrack_mute(t_mtrack *tp)
{
tp->tr_muted = 1;
}
-/* CHECKME step mode */
+/* CHECKED step and play mode */
static void mtrack_unmute(t_mtrack *tp)
{
tp->tr_muted = 0;
@@ -275,40 +296,39 @@ static void mtrack_delay(t_mtrack *tp, t_floatarg f)
ap->a_w.w_float = f;
}
-/* CHECKME */
static void mtrack_first(t_mtrack *tp, t_floatarg f)
{
- mtrack_delay(tp, f);
+ mtrack_delay(tp, f); /* CHECKED */
}
-static void mtr_doread(t_mtr *x, t_symbol *fn, int trackid);
-static void mtr_dowrite(t_mtr *x, t_symbol *fn, int trackid);
+static void mtr_doread(t_mtr *x, t_mtrack *target, t_symbol *fname);
+static void mtr_dowrite(t_mtr *x, t_mtrack *source, t_symbol *fname);
-static void mtrack_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
+static void mtrack_readhook(t_pd *z, t_symbol *fname, int ac, t_atom *av)
{
t_mtrack *tp = (t_mtrack *)z;
- mtr_doread(tp->tr_owner, fn, tp->tr_id);
+ mtr_doread(tp->tr_owner, tp, fname);
}
-static void mtrack_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
+static void mtrack_writehook(t_pd *z, t_symbol *fname, int ac, t_atom *av)
{
t_mtrack *tp = (t_mtrack *)z;
- mtr_dowrite(tp->tr_owner, fn, tp->tr_id);
+ mtr_dowrite(tp->tr_owner, tp, fname);
}
static void mtrack_read(t_mtrack *tp, t_symbol *s)
{
if (s && s != &s_)
- mtr_doread(tp->tr_owner, s, tp->tr_id);
- else /* CHECKME default */
+ mtr_doread(tp->tr_owner, tp, s);
+ else /* CHECKED no default */
hammerpanel_open(tp->tr_filehandle);
}
static void mtrack_write(t_mtrack *tp, t_symbol *s)
{
if (s && s != &s_)
- mtr_dowrite(tp->tr_owner, s, tp->tr_id);
- else /* CHECKME default */
+ mtr_dowrite(tp->tr_owner, tp, s);
+ else /* CHECKED no default */
hammerpanel_save(tp->tr_filehandle,
canvas_getdir(tp->tr_owner->x_glist), 0);
}
@@ -327,7 +347,7 @@ static void mtrack_tempo(t_mtrack *tp, t_floatarg f)
else if (f > 1e20)
f = 1e20;
newtempo = 1. / f;
- if (tp->tr_prevtime > 0)
+ if (tp->tr_prevtime > 0.)
{
tp->tr_clockdelay -= clock_gettimesince(tp->tr_prevtime);
tp->tr_clockdelay *= newtempo / tp->tr_tempo;
@@ -339,19 +359,22 @@ static void mtrack_tempo(t_mtrack *tp, t_floatarg f)
tp->tr_tempo = newtempo;
}
-/* CHECKME out-of-bounds and non-floats, which track goes first */
-static void mtr_callem(t_mtr *x, t_mtrackfn fn, t_symbol *s, int ac, t_atom *av)
+static void mtr_calltracks(t_mtr *x, t_mtrackfn fn,
+ t_symbol *s, int ac, t_atom *av)
{
int ntracks = x->x_ntracks;
t_mtrack **tpp = x->x_tracks;
if (ac)
{
+ /* FIXME: CHECKED tracks called in the order of being mentioned
+ (without duplicates) */
while (ntracks--) (*tpp++)->tr_listed = 0;
while (ac--)
{
+ /* CHECKED silently ignoring out-of-bounds and non-ints */
if (av->a_type == A_FLOAT)
{
- int id = (int)av->a_w.w_float;
+ int id = (int)av->a_w.w_float - 1; /* CHECKED 1-based */
if (id >= 0 && id < x->x_ntracks)
x->x_tracks[id]->tr_listed = 1;
}
@@ -370,42 +393,42 @@ static void mtr_callem(t_mtr *x, t_mtrackfn fn, t_symbol *s, int ac, t_atom *av)
static void mtr_record(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_record, s, ac, av);
+ mtr_calltracks(x, mtrack_record, s, ac, av);
}
static void mtr_play(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_play, s, ac, av);
+ mtr_calltracks(x, mtrack_play, s, ac, av);
}
static void mtr_stop(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_stop, s, ac, av);
+ mtr_calltracks(x, mtrack_stop, s, ac, av);
}
static void mtr_next(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_next, s, ac, av);
+ mtr_calltracks(x, mtrack_next, s, ac, av);
}
static void mtr_rewind(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_rewind, s, ac, av);
+ mtr_calltracks(x, mtrack_rewind, s, ac, av);
}
static void mtr_mute(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_mute, s, ac, av);
+ mtr_calltracks(x, mtrack_mute, s, ac, av);
}
static void mtr_unmute(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_unmute, s, ac, av);
+ mtr_calltracks(x, mtrack_unmute, s, ac, av);
}
static void mtr_clear(t_mtr *x, t_symbol *s, int ac, t_atom *av)
{
- mtr_callem(x, mtrack_clear, s, ac, av);
+ mtr_calltracks(x, mtrack_clear, s, ac, av);
}
static void mtr_delay(t_mtr *x, t_floatarg f)
@@ -449,109 +472,214 @@ static void mtr_first(t_mtr *x, t_floatarg f)
}
}
-static void mtr_doread(t_mtr *x, t_symbol *fn, int trackid)
+static void mtr_doread(t_mtr *x, t_mtrack *target, t_symbol *fname)
{
char path[MAXPDSTRING];
+ FILE *fp;
if (x->x_glist)
- canvas_makefilename(x->x_glist, fn->s_name, path, MAXPDSTRING);
+ canvas_makefilename(x->x_glist, fname->s_name, path, MAXPDSTRING);
else
{
- strncpy(path, fn->s_name, MAXPDSTRING);
+ strncpy(path, fname->s_name, MAXPDSTRING);
path[MAXPDSTRING-1] = 0;
}
- post("mtr: reading %s", fn->s_name); /* CHECKME */
-
- if (trackid > x->x_ntracks)
- bug("mtr_doread");
-
- else
+ /* CHECKED no global message */
+ sys_bashfilename(path, path);
+ if (fp = fopen(path, "r"))
{
- FILE *fp;
- char namebuf[MAXPDSTRING];
- sys_bashfilename(fn->s_name, namebuf);
- if (fp = fopen(namebuf, "r"))
+ t_mtrack *tp = 0;
+ char linebuf[MTR_FILEBUFSIZE];
+ t_binbuf *bb = binbuf_new();
+ while (fgets(linebuf, MTR_FILEBUFSIZE, fp))
{
- /* FIXME */
- fclose(fp);
- }
- else
- {
- /* CHECKME no complaint, open dialog presented */
- hammerpanel_open(x->x_filehandle); /* LATER rethink */
+ char *line = linebuf;
+ int linelen;
+ while (*line && (*line == ' ' || *line == '\t')) line++;
+ if (linelen = strlen(line))
+ {
+ if (tp)
+ {
+ if (!strncmp(line, "end;", 4))
+ {
+ post("ok");
+ tp = 0;
+ }
+ else
+ {
+ int ac;
+ binbuf_text(bb, line, linelen);
+ if (ac = binbuf_getnatom(bb))
+ {
+ t_atom *ap = binbuf_getvec(bb);
+ if (!binbuf_getnatom(tp->tr_binbuf))
+ {
+ if (ap->a_type != A_FLOAT)
+ {
+ t_atom at;
+ SETFLOAT(&at, 0.);
+ binbuf_add(tp->tr_binbuf, 1, &at);
+ }
+ else if (ap->a_w.w_float < 0.)
+ ap->a_w.w_float = 0.;
+ }
+ binbuf_add(tp->tr_binbuf, ac, ap);
+ }
+ }
+ }
+ else if (!strncmp(line, "track ", 6))
+ {
+ int id = strtol(line + 6, 0, 10);
+ startpost("Track %d... ", id);
+ if (id < 1 || id > x->x_ntracks)
+ post("no such track"); /* LATER rethink */
+ else if (target)
+ {
+ if (id == target->tr_id)
+ tp = target;
+ post("skipped"); /* LATER rethink */
+ }
+ else tp = x->x_tracks[id - 1];
+ if (tp)
+ {
+ binbuf_clear(tp->tr_binbuf);
+ }
+ }
+ }
}
+ fclose(fp);
+ binbuf_free(bb);
+ }
+ else
+ {
+ /* CHECKED no complaint, open dialog not presented... */
+ /* LATER rethink */
+ hammerpanel_open(target ? target->tr_filehandle : x->x_filehandle);
}
}
-static int mtr_writetrack(t_mtr *x, t_mtrack *tp)
+static int mtr_writetrack(t_mtr *x, t_mtrack *tp, FILE *fp)
{
- /* CHECKME complaint and FIXME */
- loud_error((t_pd *)x, "error writing text file");
+ int natoms = binbuf_getnatom(tp->tr_binbuf);
+ if (natoms) /* CHECKED empty tracks not stored */
+ {
+ char sbuf[MTR_FILEBUFSIZE], *bp = sbuf, *ep = sbuf + MTR_FILEBUFSIZE;
+ int ncolumn = 0;
+ t_atom *ap = binbuf_getvec(tp->tr_binbuf);
+ fprintf(fp, "track %d;\n", tp->tr_id);
+ for (; natoms--; ap++)
+ {
+ int length;
+ /* from binbuf_write():
+ ``estimate how many characters will be needed. Printing out
+ symbols may need extra characters for inserting backslashes.'' */
+ if (ap->a_type == A_SYMBOL || ap->a_type == A_DOLLSYM)
+ length = 80 + strlen(ap->a_w.w_symbol->s_name);
+ else
+ length = 40;
+ if (bp > sbuf && ep - bp < length)
+ {
+ if (fwrite(sbuf, bp - sbuf, 1, fp) < 1)
+ return (1);
+ bp = sbuf;
+ }
+ if (ap->a_type == A_SEMI)
+ {
+ *bp++ = ';';
+ *bp++ = '\n';
+ ncolumn = 0;
+ }
+ else if (ap->a_type == A_COMMA)
+ {
+ *bp++ = ',';
+ ncolumn++;
+ }
+ else
+ {
+ if (ncolumn)
+ {
+ *bp++ = ' ';
+ ncolumn++;
+ }
+ atom_string(ap, bp, (ep - bp) - 2);
+ length = strlen(bp);
+ if (ncolumn && ncolumn + length > MTR_FILEMAXCOLUMNS)
+ {
+ bp[-1] = '\n';
+ ncolumn = length;
+ }
+ else ncolumn += length;
+ bp += length;
+ }
+ }
+ if (bp > sbuf && fwrite(sbuf, bp - sbuf, 1, fp) < 1)
+ return (1);
+ fputs("end;\n", fp);
+ post("Track %d done", tp->tr_id); /* CHECKED (0-based: not emulated) */
+ }
return (0);
}
-static void mtr_dowrite(t_mtr *x, t_symbol *fn, int trackid)
+/* CHECKED empty sequence stored as an empty file */
+static void mtr_dowrite(t_mtr *x, t_mtrack *source, t_symbol *fname)
{
+ int failed = 0;
char path[MAXPDSTRING];
+ FILE *fp;
if (x->x_glist)
- canvas_makefilename(x->x_glist, fn->s_name, path, MAXPDSTRING);
+ canvas_makefilename(x->x_glist, fname->s_name, path, MAXPDSTRING);
else
{
- strncpy(path, fn->s_name, MAXPDSTRING);
+ strncpy(path, fname->s_name, MAXPDSTRING);
path[MAXPDSTRING-1] = 0;
}
- post("mtr: writing %s", fn->s_name); /* CHECKME */
-
- if (trackid > x->x_ntracks)
- bug("mtr_dowrite");
-
- /* CHECKME empty sequence stored as an empty file */
- else
+ /* CHECKED no global message */
+ sys_bashfilename(path, path);
+ if (fp = fopen(path, "w"))
{
- FILE *fp;
- char namebuf[MAXPDSTRING];
- sys_bashfilename(fn->s_name, namebuf);
- if (fp = fopen(namebuf, "w"))
+ /* CHECKED single-track writing does not seem to work (a bug?) */
+ if (source) failed = mtr_writetrack(x, source, fp);
+ else
{
int id;
t_mtrack **tpp;
- if (trackid >= 0)
- mtr_writetrack(x, x->x_tracks[trackid]);
- else for (id = 0, tpp = x->x_tracks; id < x->x_ntracks; id++, tpp++)
- if (!mtr_writetrack(x, *tpp))
+ for (id = 0, tpp = x->x_tracks; id < x->x_ntracks; id++, tpp++)
+ if (failed = mtr_writetrack(x, *tpp, fp))
break;
- fclose(fp);
- }
- else
- {
- fprintf(stderr, "open: ");
- sys_unixerror(fn->s_name);
}
+ if (failed) sys_unixerror(path); /* LATER rethink */
+ fclose(fp);
}
+ else
+ {
+ sys_unixerror(path); /* LATER rethink */
+ failed = 1;
+ }
+ if (failed) loud_error((t_pd *)x, "writing text file \"%s\" failed", path);
}
-static void mtr_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
+static void mtr_readhook(t_pd *z, t_symbol *fname, int ac, t_atom *av)
{
- mtr_doread((t_mtr *)z, fn, -1);
+ mtr_doread((t_mtr *)z, 0, fname);
}
-static void mtr_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
+static void mtr_writehook(t_pd *z, t_symbol *fname, int ac, t_atom *av)
{
- mtr_dowrite((t_mtr *)z, fn, -1);
+ mtr_dowrite((t_mtr *)z, 0, fname);
}
static void mtr_read(t_mtr *x, t_symbol *s)
{
if (s && s != &s_)
- mtr_doread(x, s, -1);
- else /* CHECKME default */
+ mtr_doread(x, 0, s);
+ else /* CHECKED no default */
hammerpanel_open(x->x_filehandle);
}
static void mtr_write(t_mtr *x, t_symbol *s)
{
if (s && s != &s_)
- mtr_dowrite(x, s, -1);
- else /* CHECKME default */
+ mtr_dowrite(x, 0, s);
+ else /* CHECKED no default */
hammerpanel_save(x->x_filehandle, canvas_getdir(x->x_glist), 0);
}
@@ -562,6 +690,19 @@ static void mtr_tempo(t_mtr *x, t_floatarg f)
while (ntracks--) mtrack_tempo(*tpp++, f);
}
+#ifdef MTR_DEBUG
+static void mtr_debug(t_mtr *x)
+{
+ int ntracks = x->x_ntracks;
+ t_mtrack **tpp = x->x_tracks;
+ while (ntracks--)
+ {
+ post("------- Track %d -------", (*tpp)->tr_id);
+ binbuf_print((*tpp++)->tr_binbuf);
+ }
+}
+#endif
+
static void mtr_free(t_mtr *x)
{
if (x->x_tracks)
@@ -615,9 +756,11 @@ static void *mtr_new(t_floatarg f)
x->x_glist = canvas_getcurrent();
x->x_filehandle = hammerfile_new((t_pd *)x, 0,
mtr_readhook, mtr_writehook, 0);
+ if (ntracks > MTR_C74MAXTRACKS)
+ loud_incompatible_max(mtr_class, MTR_C74MAXTRACKS, "tracks");
x->x_ntracks = ntracks;
x->x_tracks = tracks;
- for (id = 0; id < ntracks; id++, tracks++) /* CHECKME 0-based */
+ for (id = 1; id <= ntracks; id++, tracks++) /* CHECKED 1-based */
{
t_mtrack *tp = *tracks;
inlet_new((t_object *)x, (t_pd *)tp, 0, 0);
@@ -633,10 +776,10 @@ static void *mtr_new(t_floatarg f)
tp->tr_muted = 0;
tp->tr_restarted = 0;
tp->tr_atdelta = 0;
- tp->tr_ixnext = -1;
+ tp->tr_ixnext = 0;
tp->tr_tempo = 1.;
- tp->tr_clockdelay = 0;
- tp->tr_prevtime = 0;
+ tp->tr_clockdelay = 0.;
+ tp->tr_prevtime = 0.;
}
}
}
@@ -708,5 +851,9 @@ void mtr_setup(void)
gensym("write"), A_DEFSYM, 0);
class_addmethod(mtr_class, (t_method)mtr_tempo,
gensym("tempo"), A_FLOAT, 0);
+#ifdef MTR_DEBUG
+ class_addmethod(mtr_class, (t_method)mtr_debug,
+ gensym("debug"), 0);
+#endif
hammerfile_setup(mtr_class, 0);
}
diff --git a/cyclone/hammer/past.c b/cyclone/hammer/past.c
index eb29c8e..cb0b4ef 100644
--- a/cyclone/hammer/past.c
+++ b/cyclone/hammer/past.c
@@ -13,7 +13,7 @@
#include "common/loud.h"
#include "common/grow.h"
-#define PAST_MAXSIZE 8 /* CHECKED */
+#define PAST_C74MAXSIZE 8 /* CHECKED */
typedef struct past
{
@@ -22,7 +22,7 @@ typedef struct past
int x_size; /* as allocated */
int x_nthresh; /* as used */
t_atom *x_thresh;
- t_atom x_thrini[PAST_MAXSIZE];
+ t_atom x_thrini[PAST_C74MAXSIZE];
} t_past;
static t_class *past_class;
@@ -112,9 +112,9 @@ static void past_set(t_past *x, t_symbol *s, int ac, t_atom *av)
t_atom *vp = x->x_thresh;
if (ac > x->x_size)
{
- loud_incompatible_max(past_class, PAST_MAXSIZE, "guard points");
+ loud_incompatible_max(past_class, PAST_C74MAXSIZE, "guard points");
x->x_thresh = grow_nodata(&ac, &x->x_size, x->x_thresh,
- PAST_MAXSIZE, x->x_thrini,
+ PAST_C74MAXSIZE, x->x_thrini,
sizeof(*x->x_thresh));
}
x->x_nthresh = ac;
@@ -134,7 +134,7 @@ static void *past_new(t_symbol *s, int ac, t_atom *av)
t_past *x = (t_past *)pd_new(past_class);
x->x_low = 1;
x->x_nthresh = 0;
- x->x_size = PAST_MAXSIZE;
+ x->x_size = PAST_C74MAXSIZE;
x->x_thresh = x->x_thrini;
outlet_new((t_object *)x, &s_bang);
past_set(x, 0, ac, av);
diff --git a/cyclone/hammer/switch.c b/cyclone/hammer/switch.c
index 69317a1..d69660d 100644
--- a/cyclone/hammer/switch.c
+++ b/cyclone/hammer/switch.c
@@ -5,9 +5,9 @@
#include "m_pd.h"
#include "common/loud.h"
-#define SWITCH_MININLETS 2 /* LATER consider using 1 (with a warning) */
-#define SWITCH_MAXINLETS 100
-#define SWITCH_DEFINLETS 2
+#define SWITCH_MININLETS 2 /* LATER consider using 1 (with a warning) */
+#define SWITCH_C74MAXINLETS 100
+#define SWITCH_DEFINLETS 2
typedef struct _switch
{
@@ -102,8 +102,8 @@ static void *switch_new(t_floatarg f1, t_floatarg f2)
t_pd **proxies;
if (nproxies < SWITCH_MININLETS)
nproxies = SWITCH_DEFINLETS;
- if (nproxies > SWITCH_MAXINLETS)
- loud_incompatible_max(switch_class, SWITCH_MAXINLETS, "inlets");
+ if (nproxies > SWITCH_C74MAXINLETS)
+ loud_incompatible_max(switch_class, SWITCH_C74MAXINLETS, "inlets");
if (!(proxies = (t_pd **)getbytes(nproxies * sizeof(*proxies))))
return (0);
for (ninlets = 0; ninlets < nproxies; ninlets++)
diff --git a/cyclone/hammer/urn.c b/cyclone/hammer/urn.c
index 59b140e..37aaae0 100644
--- a/cyclone/hammer/urn.c
+++ b/cyclone/hammer/urn.c
@@ -12,9 +12,9 @@
#include "common/rand.h"
#include "common/grow.h"
-#define URN_INISIZE 128 /* LATER rethink */
-#define URN_MAXSIZE 4096 /* CHECKED */
-#define URN_MAXIMUMSIZE 65536 /* LATER use USHRT_MAX */
+#define URN_INISIZE 128 /* LATER rethink */
+#define URN_C74MAXSIZE 4096 /* CHECKED */
+#define URN_MAXSIZE 65536 /* LATER use USHRT_MAX */
typedef struct _urn
{
@@ -32,7 +32,7 @@ static t_class *urn_class;
static int urn_resize(t_urn *x, t_float f, int init)
{
- int maxmax = URN_MAXSIZE;
+ int maxmax = URN_C74MAXSIZE;
int range = (int)f; /* CHECKED silent truncation */
if (init)
{
@@ -48,12 +48,12 @@ static int urn_resize(t_urn *x, t_float f, int init)
loud_error((t_pd *)x, "illegal size %d", f);
return (0);
}
- if (range > URN_MAXIMUMSIZE)
+ if (range > URN_MAXSIZE)
{
loud_warning((t_pd *)x,
"requested size (%d) clipped -- effective size is %d",
- range, URN_MAXIMUMSIZE);
- range = URN_MAXIMUMSIZE;
+ range, URN_MAXSIZE);
+ range = URN_MAXSIZE;
}
if (range > maxmax)
loud_incompatible_max(urn_class, maxmax, "elements");
diff --git a/cyclone/sickle/Makefile.sources b/cyclone/sickle/Makefile.sources
index 0cb46aa..b4a5d75 100644
--- a/cyclone/sickle/Makefile.sources
+++ b/cyclone/sickle/Makefile.sources
@@ -41,6 +41,8 @@ Line.c \
linedrive.c \
log.c \
lookup.c \
+maximum.c \
+minimum.c \
minmax.c \
peakamp.c \
peek.c \
diff --git a/cyclone/sickle/allsickles.c b/cyclone/sickle/allsickles.c
index dd97ad2..f543879 100644
--- a/cyclone/sickle/allsickles.c
+++ b/cyclone/sickle/allsickles.c
@@ -44,6 +44,8 @@ void kink_tilde_setup(void);
void linedrive_setup(void);
void log_tilde_setup(void);
void lookup_tilde_setup(void);
+void maximum_tilde_setup(void);
+void minimum_tilde_setup(void);
void minmax_tilde_setup(void);
void peakamp_tilde_setup(void);
void peek_tilde_setup(void);
@@ -110,6 +112,8 @@ void allsickles_setup(void)
linedrive_setup();
log_tilde_setup();
lookup_tilde_setup();
+ maximum_tilde_setup();
+ minimum_tilde_setup();
minmax_tilde_setup();
peakamp_tilde_setup();
peek_tilde_setup();
diff --git a/cyclone/sickle/maximum.c b/cyclone/sickle/maximum.c
new file mode 100644
index 0000000..8d947ec
--- /dev/null
+++ b/cyclone/sickle/maximum.c
@@ -0,0 +1,50 @@
+/* Copyright (c) 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. */
+
+/* LATER use hasfeeders */
+
+#include "m_pd.h"
+#include "sickle/sic.h"
+
+#define MAXIMUM_DEFRHS 0. /* CHECKED */
+
+typedef t_sic t_maximum;
+static t_class *maximum_class;
+
+static t_int *maximum_perform(t_int *w)
+{
+ int nblock = (int)(w[1]);
+ t_float *in1 = (t_float *)(w[2]);
+ t_float *in2 = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
+ while (nblock--)
+ {
+ t_float f1 = *in1++;
+ t_float f2 = *in2++;
+ *out++ = (f1 > f2 ? f1 : f2);
+ }
+ return (w + 5);
+}
+
+static void maximum_dsp(t_maximum *x, t_signal **sp)
+{
+ dsp_add(maximum_perform, 4, sp[0]->s_n,
+ sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec);
+}
+
+static void *maximum_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_maximum *x = (t_maximum *)pd_new(maximum_class);
+ sic_inlet((t_sic *)x, 1, MAXIMUM_DEFRHS, 0, ac, av);
+ outlet_new((t_object *)x, &s_signal);
+ return (x);
+}
+
+void maximum_tilde_setup(void)
+{
+ maximum_class = class_new(gensym("maximum~"),
+ (t_newmethod)maximum_new, 0,
+ sizeof(t_maximum), 0, A_GIMME, 0);
+ sic_setup(maximum_class, maximum_dsp, SIC_FLOATTOSIGNAL);
+}
diff --git a/cyclone/sickle/minimum.c b/cyclone/sickle/minimum.c
new file mode 100644
index 0000000..cb31f49
--- /dev/null
+++ b/cyclone/sickle/minimum.c
@@ -0,0 +1,50 @@
+/* Copyright (c) 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. */
+
+/* LATER use hasfeeders */
+
+#include "m_pd.h"
+#include "sickle/sic.h"
+
+#define MINIMUM_DEFRHS 0. /* CHECKED */
+
+typedef t_sic t_minimum;
+static t_class *minimum_class;
+
+static t_int *minimum_perform(t_int *w)
+{
+ int nblock = (int)(w[1]);
+ t_float *in1 = (t_float *)(w[2]);
+ t_float *in2 = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
+ while (nblock--)
+ {
+ t_float f1 = *in1++;
+ t_float f2 = *in2++;
+ *out++ = (f1 < f2 ? f1 : f2);
+ }
+ return (w + 5);
+}
+
+static void minimum_dsp(t_minimum *x, t_signal **sp)
+{
+ dsp_add(minimum_perform, 4, sp[0]->s_n,
+ sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec);
+}
+
+static void *minimum_new(t_symbol *s, int ac, t_atom *av)
+{
+ t_minimum *x = (t_minimum *)pd_new(minimum_class);
+ sic_inlet((t_sic *)x, 1, MINIMUM_DEFRHS, 0, ac, av);
+ outlet_new((t_object *)x, &s_signal);
+ return (x);
+}
+
+void minimum_tilde_setup(void)
+{
+ minimum_class = class_new(gensym("minimum~"),
+ (t_newmethod)minimum_new, 0,
+ sizeof(t_minimum), 0, A_GIMME, 0);
+ sic_setup(minimum_class, minimum_dsp, SIC_FLOATTOSIGNAL);
+}
diff --git a/cyclone/sickle/pong.c b/cyclone/sickle/pong.c
index 59a8beb..d52ed44 100644
--- a/cyclone/sickle/pong.c
+++ b/cyclone/sickle/pong.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002-2003 krzYszcz and others.
+/* Copyright (c) 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. */
@@ -243,5 +243,5 @@ void pong_tilde_setup(void)
sizeof(t_pong), 0, A_GIMME, 0);
sic_setup(pong_class, pong_dsp, SIC_FLOATTOSIGNAL);
class_addmethod(pong_class, (t_method)pong_mode,
- gensym("mode"), A_FLOAT, 0);
+ gensym("mode"), A_DEFFLOAT, 0); /* CHECKED default */
}