aboutsummaryrefslogtreecommitdiff
path: root/cyclone/hammer
diff options
context:
space:
mode:
Diffstat (limited to 'cyclone/hammer')
-rw-r--r--cyclone/hammer/Append.c13
-rw-r--r--cyclone/hammer/Decode.c2
-rw-r--r--cyclone/hammer/Makefile.objects1
-rw-r--r--cyclone/hammer/bangbang.c2
-rw-r--r--cyclone/hammer/counter.c2
-rw-r--r--cyclone/hammer/cycle.c2
-rw-r--r--cyclone/hammer/gate.c2
-rw-r--r--cyclone/hammer/hammer.c38
-rw-r--r--cyclone/hammer/maximum.c2
-rw-r--r--cyclone/hammer/minimum.c2
-rw-r--r--cyclone/hammer/mtr.c2
-rw-r--r--cyclone/hammer/past.c2
-rw-r--r--cyclone/hammer/prepend.c15
-rw-r--r--cyclone/hammer/prob.c2
-rw-r--r--cyclone/hammer/seq.c101
-rw-r--r--cyclone/hammer/switch.c2
-rw-r--r--cyclone/hammer/urn.c2
17 files changed, 138 insertions, 54 deletions
diff --git a/cyclone/hammer/Append.c b/cyclone/hammer/Append.c
index 16b65cc..4be4807 100644
--- a/cyclone/hammer/Append.c
+++ b/cyclone/hammer/Append.c
@@ -34,8 +34,7 @@ typedef struct _appendxy
static t_class *append_class;
static t_class *appendxy_class;
-static t_symbol *appendps_compatibility = 0;
-static t_symbol *appendps_max;
+static int append_iscompatible = 0; /* FIXME per-object */
/* Usually a preallocation method is used, except in special cases of:
1) reentrant output request, or 2) an output request which would cause
@@ -155,7 +154,7 @@ static void append_anything(t_append *x, t_symbol *s, int ac, t_atom *av)
static void append_bang(t_append *x)
{
- if (appendps_compatibility == appendps_max)
+ if (append_iscompatible)
{
/* CHECKED: a nop */
}
@@ -325,6 +324,11 @@ static void *append_new(t_symbol *s, int ac, t_atom *av)
return (x);
}
+static void append_fitter(void)
+{
+ append_iscompatible = fittermax_get();
+}
+
void Append_setup(void)
{
append_class = class_new(gensym("Append"),
@@ -348,6 +352,5 @@ void Append_setup(void)
class_addlist(appendxy_class, appendxy_list);
class_addanything(appendxy_class, appendxy_anything);
- appendps_max = gensym("max");
- fitter_setup(append_class, &appendps_compatibility, 0);
+ fitter_setup(append_class, append_fitter);
}
diff --git a/cyclone/hammer/Decode.c b/cyclone/hammer/Decode.c
index 0342594..0d62237 100644
--- a/cyclone/hammer/Decode.c
+++ b/cyclone/hammer/Decode.c
@@ -108,5 +108,5 @@ void Decode_setup(void)
gensym("ft1"), A_FLOAT, 0);
class_addmethod(Decode_class, (t_method)Decode_alloff,
gensym("ft2"), A_FLOAT, 0);
- fitter_setup(Decode_class, 0, 0);
+ fitter_setup(Decode_class, 0);
}
diff --git a/cyclone/hammer/Makefile.objects b/cyclone/hammer/Makefile.objects
index eb54f17..a7099d8 100644
--- a/cyclone/hammer/Makefile.objects
+++ b/cyclone/hammer/Makefile.objects
@@ -4,6 +4,7 @@ unstable/fragile.o \
unstable/fringe.o \
common/loud.o \
common/grow.o \
+common/os.o \
common/fitter.o \
common/rand.o \
common/vefl.o \
diff --git a/cyclone/hammer/bangbang.c b/cyclone/hammer/bangbang.c
index 5ae3506..aa8363d 100644
--- a/cyclone/hammer/bangbang.c
+++ b/cyclone/hammer/bangbang.c
@@ -71,5 +71,5 @@ void bangbang_setup(void)
sizeof(t_bangbang), 0, A_DEFFLOAT, 0);
class_addbang(bangbang_class, bangbang_bang);
class_addanything(bangbang_class, bangbang_anything);
- fitter_setup(bangbang_class, 0, 0);
+ fitter_setup(bangbang_class, 0);
}
diff --git a/cyclone/hammer/counter.c b/cyclone/hammer/counter.c
index 0b29b3f..dd987d4 100644
--- a/cyclone/hammer/counter.c
+++ b/cyclone/hammer/counter.c
@@ -398,5 +398,5 @@ void counter_setup(void)
CLASS_PD | CLASS_NOINLET, 0);
class_addbang(counter_proxy_class, counter_proxy_bang);
class_addfloat(counter_proxy_class, counter_proxy_float);
- fitter_setup(counter_class, 0, 0);
+ fitter_setup(counter_class, 0);
}
diff --git a/cyclone/hammer/cycle.c b/cyclone/hammer/cycle.c
index 73f3b80..5063629 100644
--- a/cyclone/hammer/cycle.c
+++ b/cyclone/hammer/cycle.c
@@ -151,5 +151,5 @@ void cycle_setup(void)
gensym("set"), A_FLOAT, 0); /* CHECKED: arg required */
class_addmethod(cycle_class, (t_method)cycle_thresh,
gensym("thresh"), A_FLOAT, 0);
- fitter_setup(cycle_class, 0, 0);
+ fitter_setup(cycle_class, 0);
}
diff --git a/cyclone/hammer/gate.c b/cyclone/hammer/gate.c
index 6fa2ac5..d626906 100644
--- a/cyclone/hammer/gate.c
+++ b/cyclone/hammer/gate.c
@@ -145,5 +145,5 @@ void gate_setup(void)
class_addpointer(gate_proxy_class, gate_proxy_pointer);
class_addlist(gate_proxy_class, gate_proxy_list);
class_addanything(gate_proxy_class, gate_proxy_anything);
- fitter_setup(gate_class, 0, 0);
+ fitter_setup(gate_class, 0);
}
diff --git a/cyclone/hammer/hammer.c b/cyclone/hammer/hammer.c
index a728ec7..7e0d6e4 100644
--- a/cyclone/hammer/hammer.c
+++ b/cyclone/hammer/hammer.c
@@ -13,8 +13,6 @@ void allhammers_setup(void);
typedef struct _hammer
{
t_object x_ob;
- t_symbol *x_dir;
- t_symbol *x_canvasdir;
t_hammerfile *x_filehandle;
} t_hammer;
@@ -24,39 +22,43 @@ static int hammer_lastndx;
static void hammer_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
{
- import_max(fn->s_name, "");
+ int result = import_max(fn->s_name, "");
+ outlet_float(((t_object *)z)->ob_outlet, (t_float)result);
}
-static void hammer_doimport(t_hammer *x, t_symbol *fn, t_symbol *dir)
+static void hammer_doimport(t_hammer *x, t_symbol *fn)
{
- if (!dir || dir == &s_)
- dir = x->x_dir;
if (fn && fn != &s_)
- import_max(fn->s_name, (dir && dir != &s_) ? dir->s_name : "");
- else
- hammerpanel_open(x->x_filehandle, dir);
+ {
+ t_symbol *dir = hammerpanel_getopendir(x->x_filehandle);
+ int result =
+ import_max(fn->s_name, (dir && dir != &s_ ? dir->s_name : ""));
+ outlet_float(((t_object *)x)->ob_outlet, (t_float)result);
+ }
+ else hammerpanel_open(x->x_filehandle, 0);
}
static void hammer_click(t_hammer *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{
- hammer_doimport(x, 0, 0);
+ hammer_doimport(x, 0);
}
static void hammer_import(t_hammer *x, t_symbol *fn)
{
- hammer_doimport(x, fn, 0);
+ hammer_doimport(x, fn);
}
static void hammer_cd(t_hammer *x, t_symbol *dir)
{
- /* LATER hammerfile interface for relative jumps, etc. */
- x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir);
+ hammerpanel_setopendir(x->x_filehandle, dir);
}
-static void hammer_pwd(t_hammer *x)
+static void hammer_pwd(t_hammer *x, t_symbol *s)
{
- outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir);
+ t_symbol *dir;
+ if (s && s->s_thing && (dir = hammerpanel_getopendir(x->x_filehandle)))
+ pd_symbol(s->s_thing, dir);
}
static void hammer_bang(t_hammer *x)
@@ -74,9 +76,7 @@ static void *hammer_new(void)
{
t_hammer *x = (t_hammer *)pd_new(hammer_class);
x->x_filehandle = hammerfile_new((t_pd *)x, 0, hammer_readhook, 0, 0);
- x->x_canvasdir = canvas_getdir(x->x_filehandle->f_canvas);
- x->x_dir = x->x_canvasdir;
- outlet_new((t_object *)x, &s_symbol);
+ outlet_new((t_object *)x, &s_float);
return (x);
}
@@ -106,7 +106,7 @@ void hammer_setup(void)
class_addmethod(hammer_class, (t_method)hammer_cd,
gensym("cd"), A_DEFSYM, 0);
class_addmethod(hammer_class, (t_method)hammer_pwd,
- gensym("pwd"), 0);
+ gensym("pwd"), A_SYMBOL, 0);
class_addmethod(hammer_class, (t_method)hammer_import,
gensym("import"), A_DEFSYM, 0);
class_addmethod(hammer_class, (t_method)hammer_click,
diff --git a/cyclone/hammer/maximum.c b/cyclone/hammer/maximum.c
index 5f49765..42ab22d 100644
--- a/cyclone/hammer/maximum.c
+++ b/cyclone/hammer/maximum.c
@@ -89,5 +89,5 @@ void maximum_setup(void)
class_addbang(maximum_class, maximum_bang);
class_addfloat(maximum_class, maximum_float);
class_addlist(maximum_class, maximum_list);
- fitter_setup(maximum_class, 0, 0);
+ fitter_setup(maximum_class, 0);
}
diff --git a/cyclone/hammer/minimum.c b/cyclone/hammer/minimum.c
index a1124a5..c679799 100644
--- a/cyclone/hammer/minimum.c
+++ b/cyclone/hammer/minimum.c
@@ -89,5 +89,5 @@ void minimum_setup(void)
class_addbang(minimum_class, minimum_bang);
class_addfloat(minimum_class, minimum_float);
class_addlist(minimum_class, minimum_list);
- fitter_setup(minimum_class, 0, 0);
+ fitter_setup(minimum_class, 0);
}
diff --git a/cyclone/hammer/mtr.c b/cyclone/hammer/mtr.c
index cf9927f..15dc5f6 100644
--- a/cyclone/hammer/mtr.c
+++ b/cyclone/hammer/mtr.c
@@ -860,5 +860,5 @@ void mtr_setup(void)
gensym("debug"), 0);
#endif
hammerfile_setup(mtr_class, 0);
- fitter_setup(mtr_class, 0, 0);
+ fitter_setup(mtr_class, 0);
}
diff --git a/cyclone/hammer/past.c b/cyclone/hammer/past.c
index 553ccfa..2ed2193 100644
--- a/cyclone/hammer/past.c
+++ b/cyclone/hammer/past.c
@@ -152,5 +152,5 @@ void past_setup(void)
class_addlist(past_class, past_list);
class_addmethod(past_class, (t_method)past_clear, gensym("clear"), 0);
class_addmethod(past_class, (t_method)past_set, gensym("set"), A_GIMME, 0);
- fitter_setup(past_class, 0, 0);
+ fitter_setup(past_class, 0);
}
diff --git a/cyclone/hammer/prepend.c b/cyclone/hammer/prepend.c
index 2dbe7be..b305f2f 100644
--- a/cyclone/hammer/prepend.c
+++ b/cyclone/hammer/prepend.c
@@ -34,8 +34,7 @@ typedef struct _prependxy
static t_class *prepend_class;
static t_class *prependxy_class;
-static t_symbol *prependps_compatibility = 0;
-static t_symbol *prependps_max;
+static int prepend_iscompatible = 0; /* FIXME per-object */
/* Usually a preallocation method is used, except in special cases of:
1) reentrant output request, or 2) an output request which would cause
@@ -153,7 +152,7 @@ static void prepend_bang(t_prepend *x)
{
if (x->x_selector)
{
- if (prependps_compatibility == prependps_max)
+ if (prepend_iscompatible)
{
t_atom at;
SETSYMBOL(&at, &s_bang); /* CHECKED */
@@ -324,7 +323,7 @@ static void *prepend_new(t_symbol *s, int ac, t_atom *av)
}
else
{
- if (prependps_compatibility == prependps_max)
+ if (prepend_iscompatible)
/* CHECKED in max an object without an outlet is created,
and there is no warning when loading from a file. */
fittermax_warning(prepend_class,
@@ -337,6 +336,11 @@ static void *prepend_new(t_symbol *s, int ac, t_atom *av)
return (x);
}
+static void prepend_fitter(void)
+{
+ prepend_iscompatible = fittermax_get();
+}
+
void prepend_setup(void)
{
prepend_class = class_new(gensym("prepend"),
@@ -360,6 +364,5 @@ void prepend_setup(void)
class_addlist(prependxy_class, prependxy_list);
class_addanything(prependxy_class, prependxy_anything);
- prependps_max = gensym("max");
- fitter_setup(prepend_class, &prependps_compatibility, 0);
+ fitter_setup(prepend_class, prepend_fitter);
}
diff --git a/cyclone/hammer/prob.c b/cyclone/hammer/prob.c
index 8772d83..2794858 100644
--- a/cyclone/hammer/prob.c
+++ b/cyclone/hammer/prob.c
@@ -307,5 +307,5 @@ void prob_setup(void)
gensym("click"),
A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
hammerfile_setup(prob_class, 1);
- fitter_setup(prob_class, 0, 0);
+ fitter_setup(prob_class, 0);
}
diff --git a/cyclone/hammer/seq.c b/cyclone/hammer/seq.c
index 97fd733..030a7ab 100644
--- a/cyclone/hammer/seq.c
+++ b/cyclone/hammer/seq.c
@@ -49,6 +49,7 @@ typedef struct _seq
t_hammerfile *x_filehandle;
int x_mode;
int x_playhead;
+ double x_nextscoretime;
float x_timescale;
float x_newtimescale;
double x_prevtime;
@@ -248,6 +249,7 @@ static void seq_stopplayback(t_seq *x)
/* CHECKED bang not sent if playback stopped early */
clock_unset(x->x_clock);
x->x_playhead = 0;
+ x->x_nextscoretime = 0.;
}
static void seq_stopslavery(t_seq *x)
@@ -256,6 +258,7 @@ static void seq_stopslavery(t_seq *x)
clock_unset(x->x_clock);
clock_unset(x->x_slaveclock);
x->x_playhead = 0;
+ x->x_nextscoretime = 0.;
}
static void seq_startrecording(t_seq *x, int modechanged)
@@ -275,21 +278,22 @@ static void seq_startplayback(t_seq *x, int modechanged)
if (modechanged)
{
x->x_playhead = 0;
+ x->x_nextscoretime = x->x_sequence->e_delta;
/* playback data never sent within the scheduler event of
a start message (even for the first delta <= 0), LATER rethink */
x->x_clockdelay = x->x_sequence->e_delta * x->x_newtimescale;
}
else
- {
- /* CHECKED timescale change */
- x->x_clockdelay -= clock_gettimesince(x->x_prevtime);
+ { /* CHECKED timescale change */
+ if (x->x_prevtime > 0.) /* running state */
+ x->x_clockdelay -= clock_gettimesince(x->x_prevtime);
x->x_clockdelay *= x->x_newtimescale / x->x_timescale;
}
if (x->x_clockdelay < 0.)
x->x_clockdelay = 0.;
+ x->x_timescale = x->x_newtimescale;
clock_delay(x->x_clock, x->x_clockdelay);
x->x_prevtime = clock_getlogicaltime();
- x->x_timescale = x->x_newtimescale;
}
else x->x_mode = SEQ_IDLEMODE;
}
@@ -299,6 +303,7 @@ static void seq_startslavery(t_seq *x, int modechanged)
if (x->x_nevents)
{
x->x_playhead = 0;
+ x->x_nextscoretime = 0.;
x->x_prevtime = 0.;
x->x_slaveprevtime = 0.;
}
@@ -380,6 +385,7 @@ nextevent:
if (x->x_playhead < x->x_nevents)
{
ep++;
+ x->x_nextscoretime += ep->e_delta;
if (ep->e_delta < SEQ_TICKEPSILON)
/* continue output in the same scheduler event, LATER rethink */
{
@@ -556,7 +562,8 @@ static void seq_pause(t_seq *x)
fittermax_warning(*(t_pd *)x, "'pause' not supported in Max");
warned = 1;
}
- if (x->x_mode == SEQ_PLAYMODE && x->x_prevtime > 0.)
+ if (x->x_mode == SEQ_PLAYMODE &&
+ x->x_prevtime > 0.) /* running state */
{
x->x_clockdelay -= clock_gettimesince(x->x_prevtime);
if (x->x_clockdelay < 0.)
@@ -574,7 +581,8 @@ static void seq_continue(t_seq *x)
fittermax_warning(*(t_pd *)x, "'continue' not supported in Max");
warned = 1;
}
- if (x->x_mode == SEQ_PLAYMODE)
+ if (x->x_mode == SEQ_PLAYMODE &&
+ x->x_prevtime <= 0.) /* pause state */
{
if (x->x_clockdelay < 0.)
x->x_clockdelay = 0.;
@@ -591,30 +599,91 @@ static void seq_goto(t_seq *x, t_floatarg f1, t_floatarg f2)
fittermax_warning(*(t_pd *)x, "'goto' not supported in Max");
warned = 1;
}
- if (x->x_nevents && x->x_mode == SEQ_PLAYMODE)
+ if (x->x_nevents)
{
t_seqevent *ev;
int ndx, nevents = x->x_nevents;
double ms = f1 * 1000. + f2, sum;
if (ms < SEQ_TICKEPSILON)
ms = 0.;
+ if (x->x_mode != SEQ_PLAYMODE)
+ {
+ seq_settimescale(x, x->x_timescale);
+ seq_setmode(x, SEQ_PLAYMODE);
+ /* clock_delay() has been called in setmode, LATER avoid */
+ clock_unset(x->x_clock);
+ x->x_prevtime = 0.;
+ }
for (ndx = 0, ev = x->x_sequence, sum = SEQ_TICKEPSILON; ndx < nevents;
ndx++, ev++)
{
if ((sum += ev->e_delta) >= ms)
{
x->x_playhead = ndx;
+ x->x_nextscoretime = sum;
x->x_clockdelay = sum - SEQ_TICKEPSILON - ms;
if (x->x_clockdelay < 0.)
x->x_clockdelay = 0.;
- clock_delay(x->x_clock, x->x_clockdelay);
- x->x_prevtime = clock_getlogicaltime();
+ if (x->x_prevtime > 0.) /* running state */
+ {
+ clock_delay(x->x_clock, x->x_clockdelay);
+ x->x_prevtime = clock_getlogicaltime();
+ }
break;
}
}
}
}
+static void seq_scoretime(t_seq *x, t_symbol *s)
+{
+ static int warned = 0;
+ if (fittermax_get() && !warned)
+ {
+ fittermax_warning(*(t_pd *)x, "'scoretime' not supported in Max");
+ warned = 1;
+ }
+ if (s && s->s_thing &&
+ x->x_mode == SEQ_PLAYMODE) /* LATER other modes */
+ {
+ t_atom aout[2];
+ double ms, clockdelay = x->x_clockdelay;
+ t_float f1, f2;
+ if (x->x_prevtime > 0.) /* running state */
+ clockdelay -= clock_gettimesince(x->x_prevtime);
+ ms = x->x_nextscoretime - clockdelay / x->x_timescale;
+ f1 = ms / 1000.;
+ f2 = ms - f1;
+ SETFLOAT(&aout[0], f1);
+ SETFLOAT(&aout[1], f2);
+ pd_list(s->s_thing, &s_list, 2, aout);
+ }
+}
+
+static void seq_cd(t_seq *x, t_symbol *s)
+{
+ static int warned = 0;
+ if (fittermax_get() && !warned)
+ {
+ fittermax_warning(*(t_pd *)x, "'cd' not supported in Max");
+ warned = 1;
+ }
+ hammerpanel_setopendir(x->x_filehandle, s);
+}
+
+static void seq_pwd(t_seq *x, t_symbol *s)
+{
+ t_symbol *dir;
+ static int warned = 0;
+ if (fittermax_get() && !warned)
+ {
+ fittermax_warning(*(t_pd *)x, "'pwd' not supported in Max");
+ warned = 1;
+ }
+ if (s && s->s_thing && (dir = hammerpanel_getopendir(x->x_filehandle)))
+ pd_symbol(s->s_thing, dir);
+}
+
static int seq_eventcomparehook(const void *e1, const void *e2)
{
return (((t_seqevent *)e1)->e_delta > ((t_seqevent *)e2)->e_delta ? 1 : -1);
@@ -963,7 +1032,8 @@ static void seq_read(t_seq *x, t_symbol *s)
{
if (s && s != &s_)
seq_doread(x, s, 0);
- else /* CHECKED no default */
+ else /* CHECKED no default file name */
+ /* start in a dir last read from, if any, otherwise in a canvas dir */
hammerpanel_open(x->x_filehandle, 0);
}
@@ -971,8 +1041,9 @@ static void seq_write(t_seq *x, t_symbol *s)
{
if (s && s != &s_)
seq_dowrite(x, s);
- else /* CHECKED creation arg is a default */
+ else /* CHECKED creation arg is a default file name */
hammerpanel_save(x->x_filehandle,
+ /* always start in canvas dir */
canvas_getdir(x->x_canvas), x->x_defname);
}
@@ -1123,8 +1194,14 @@ void seq_setup(void)
gensym("continue"), 0);
class_addmethod(seq_class, (t_method)seq_goto,
gensym("goto"), A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_addmethod(seq_class, (t_method)seq_scoretime,
+ gensym("scoretime"), A_SYMBOL, 0);
+ class_addmethod(seq_class, (t_method)seq_cd,
+ gensym("cd"), A_DEFSYM, 0);
+ class_addmethod(seq_class, (t_method)seq_pwd,
+ gensym("pwd"), A_SYMBOL, 0);
forky_setpropertiesfn(seq_class, seq_properties);
hammerfile_setup(seq_class, 0);
- fitter_setup(seq_class, 0, 0);
+ fitter_setup(seq_class, 0);
}
diff --git a/cyclone/hammer/switch.c b/cyclone/hammer/switch.c
index ce985de..2a6846e 100644
--- a/cyclone/hammer/switch.c
+++ b/cyclone/hammer/switch.c
@@ -150,5 +150,5 @@ void switch_setup(void)
class_addpointer(switch_proxy_class, switch_proxy_pointer);
class_addlist(switch_proxy_class, switch_proxy_list);
class_addanything(switch_proxy_class, switch_proxy_anything);
- fitter_setup(switch_class, 0, 0);
+ fitter_setup(switch_class, 0);
}
diff --git a/cyclone/hammer/urn.c b/cyclone/hammer/urn.c
index b02d891..a3ee8ae 100644
--- a/cyclone/hammer/urn.c
+++ b/cyclone/hammer/urn.c
@@ -146,5 +146,5 @@ void urn_setup(void)
gensym("seed"), A_FLOAT, 0); /* CHECKED arg obligatory */
class_addmethod(urn_class, (t_method)urn_clear,
gensym("clear"), 0);
- fitter_setup(urn_class, 0, 0);
+ fitter_setup(urn_class, 0);
}