diff options
author | N.N. <krzyszcz@users.sourceforge.net> | 2004-04-23 11:26:52 +0000 |
---|---|---|
committer | N.N. <krzyszcz@users.sourceforge.net> | 2004-04-23 11:26:52 +0000 |
commit | 356d0569f9eab63238e966bbb309746bcf81d490 (patch) | |
tree | 7792eab471b0deaa9a282e7464c7f85536a34a78 /cyclone/hammer | |
parent | 9847553a8b488cadffe0750fb4201ff6465b5490 (diff) |
*** empty log message ***
svn path=/trunk/externals/miXed/; revision=1629
Diffstat (limited to 'cyclone/hammer')
-rw-r--r-- | cyclone/hammer/Table.c | 69 | ||||
-rw-r--r-- | cyclone/hammer/prob.c | 55 |
2 files changed, 76 insertions, 48 deletions
diff --git a/cyclone/hammer/Table.c b/cyclone/hammer/Table.c index da19b9f..9b08cbe 100644 --- a/cyclone/hammer/Table.c +++ b/cyclone/hammer/Table.c @@ -67,6 +67,7 @@ typedef struct _table t_float x_value; int x_valueset; int x_head; + int x_intraversal; /* ``set-with-next/prev'' flag */ int x_loadflag; int x_loadndx; unsigned int x_seed; @@ -183,8 +184,9 @@ static void tablecommon_setlength(t_tablecommon *cc, int length) } cc->c_length = length; /* CHECKED values at common indices are preserved */ - /* CHECKED rewinding neither head, nor loadndx, but a separate - condition of eot is preserved only for the head. */ + /* CHECKED rewinding neither head, nor loadndx -- both are preserved, + although there is a bug in handling of 'prev' after the head + overflows due to shrinking. */ tablecommon_modified(cc, relocate); } @@ -427,8 +429,7 @@ static void table_float(t_table *x, t_float f) x->x_valueset = 0; } else table_dooutput(x, ndx); - /* CHECKME if head is updated */ - x->x_head = ndx; + /* CHECKED head is not updated */ } } @@ -500,13 +501,13 @@ static void table_cancel(t_table *x) static void table_clear(t_table *x) { tablecommon_setall(x->x_common, 0); - /* CHECKME head */ + /* CHECKED head preserved */ } static void table_const(t_table *x, t_floatarg f) { tablecommon_setall(x->x_common, (int)f); - /* CHECKME head */ + /* CHECKED head preserved */ } static void table_load(t_table *x) @@ -522,29 +523,59 @@ static void table_normal(t_table *x) static void table_next(t_table *x) { - table_dooutput(x, x->x_head++); - if (x->x_head >= x->x_common->c_length) + if (!x->x_intraversal) + x->x_intraversal = 1; + else if (++x->x_head >= x->x_common->c_length) x->x_head = 0; + table_dooutput(x, x->x_head); } static void table_prev(t_table *x) { - table_dooutput(x, x->x_head--); - if (x->x_head < 0) + if (!x->x_intraversal) + x->x_intraversal = 1; + else if (--x->x_head < 0) x->x_head = x->x_common->c_length - 1; + table_dooutput(x, x->x_head); } static void table_goto(t_table *x, t_floatarg f) { /* CHECKED floats are truncated */ x->x_head = tablecommon_getindex(x->x_common, (int)f); + /* CHECKED the head should be pre-updated during traversal, in order + to maintain the logical way of direction change. Therefore, we + need the flag below, which locks head in place that has just been + set by goto. The flag is then set by next or prev. */ + x->x_intraversal = 0; } -/* CHECKED 'send <target> length' works, but not max, min, sum... */ -/* CHECKED 'send <target> <ndx> <value>' writes the value (a bug?) */ -static void table_send(t_table *x, t_symbol *s, t_floatarg f) +static void table_send(t_table *x, t_symbol *s, int ac, t_atom *av) { - /* FIXME */ + if (ac > 1 && av->a_type == A_SYMBOL) + { + t_symbol *target = av->a_w.w_symbol; + if (!target->s_thing) + return; /* CHECKED no complaint */ + ac--; av++; + if (av->a_type == A_FLOAT) + { + if (ac == 1) + { + int ndx = (int)av->a_w.w_float; + pd_float(target->s_thing, + (t_float)tablecommon_getvalue(x->x_common, ndx)); + } + /* CHECKED incompatible: 'send <target> <ndx> <value>' + stores <value> at <ndx> (a bug?) */ + } + else if (av->a_type == A_SYMBOL) + { + /* CHECKED 'send <target> length' works, but not max, min, sum... */ + if (av->a_w.w_symbol == gensym("length")) + pd_float(target->s_thing, (t_float)x->x_common->c_length); + } + } } static void table_length(t_table *x) @@ -612,7 +643,7 @@ static void table_fquantile(t_table *x, t_floatarg f) /* FIXME arguments (from, to) */ /* CHECKED no remote dumping, symbol args bashed to 0 */ -static void table_dump(t_table *x) +static void table_dump(t_table *x, t_symbol *s, int ac, t_atom *av) { t_tablecommon *cc = x->x_common; t_outlet *out = ((t_object *)x)->ob_outlet; @@ -649,7 +680,8 @@ static void table_write(t_table *x, t_symbol *s) if (s && s != &s_) tablecommon_dowrite(cc, s, x->x_canvas); else - hammerpanel_save(cc->c_filehandle, 0, 0); /* CHECKME default name */ + /* CHECKED default name is plain `Untitled' */ + hammerpanel_save(cc->c_filehandle, 0, 0); } static int tablecommon_editorappend(t_tablecommon *cc, @@ -725,6 +757,7 @@ static void *table_new(t_symbol *s) x->x_canvas = canvas_getcurrent(); x->x_valueset = 0; x->x_head = 0; + x->x_intraversal = 0; /* CHECKED */ x->x_loadflag = 0; rand_seed(&x->x_seed, 0); inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1")); @@ -773,7 +806,7 @@ void Table_setup(void) class_addmethod(table_class, (t_method)table_goto, gensym("goto"), A_FLOAT, 0); class_addmethod(table_class, (t_method)table_send, - gensym("send"), A_SYMBOL, A_FLOAT, 0); + gensym("send"), A_GIMME, 0); class_addmethod(table_class, (t_method)table_length, gensym("length"), 0); class_addmethod(table_class, (t_method)table_sum, @@ -793,7 +826,7 @@ void Table_setup(void) class_addmethod(table_class, (t_method)table_fquantile, gensym("fquantile"), A_FLOAT, 0); class_addmethod(table_class, (t_method)table_dump, - gensym("dump"), 0); + gensym("dump"), A_GIMME, 0); class_addmethod(table_class, (t_method)table_refer, gensym("refer"), A_SYMBOL, 0); class_addmethod(table_class, (t_method)table_read, diff --git a/cyclone/hammer/prob.c b/cyclone/hammer/prob.c index 5227870..e20e420 100644 --- a/cyclone/hammer/prob.c +++ b/cyclone/hammer/prob.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002-2003 krzYszcz and others. +/* 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. */ @@ -8,8 +8,8 @@ #include "common/rand.h" #include "hammer/file.h" -/* CHECKED: no preallocation. Apparently, it looks like if the new - state-entries were added to the list's head, and the new transition-entries +/* CHECKED: no preallocation. It looks like if new state-entries + were added to the list's head, and new transition-entries were added to the sublist's head. No sorting of any kind. */ #define PROB_DEBUG 0 @@ -62,29 +62,26 @@ static void prob_reset(t_prob *x, t_floatarg f) } } -/* -CHECKED: embedmode off: -#N prob; -#P newobj ... prob; - -CHECKED: embedmode on, after clear: -#N prob; -#T embed 1; -#P newobj ... prob; +static void prob_embedhook(t_pd *z, t_binbuf *bb, t_symbol *bindsym) +{ + t_prob *x = (t_prob *)z; + if (x->x_embedmode) + { + t_probtrans *pfx, *sfx; + for (pfx = x->x_translist; pfx; pfx = pfx->tr_nextstate) + for (sfx = pfx->tr_nexttrans; sfx; sfx = sfx->tr_nexttrans) + binbuf_addv(bb, "siii;", bindsym, + pfx->tr_value, sfx->tr_value, sfx->tr_count); + binbuf_addv(bb, "ssi;", bindsym, gensym("embed"), 1); + if (x->x_default) + binbuf_addv(bb, "ssi;", bindsym, gensym("reset"), + x->x_default->tr_value); + } +} -CHECKED: embedmode on, filled: -#N prob; -#T <preffix> <suffix> <count> -... -#T embed 1; -#T reset <default>; (if set) -#P newobj ... prob; -*/ static void prob_embed(t_prob *x, t_floatarg f) { x->x_embedmode = ((int)f != 0); - if (x->x_embedmode) - loud_incompatible(prob_class, "embedding not supported (yet)..."); } static void prob_clear(t_prob *x) @@ -235,11 +232,11 @@ static void prob_list(t_prob *x, t_symbol *s, int ac, t_atom *av) else loud_error((t_pd *)x, "bad list message format"); /* CHECKED */ } -static void prob_silent(t_prob *x) +static void prob__silent(t_prob *x) { if (!x->x_silent) { - loud_incompatible(prob_class, "no 'silent' message in max"); + loud_incompatible(prob_class, "no '_silent' message in max"); x->x_silent = 1; } } @@ -279,7 +276,7 @@ static void *prob_new(void) rand_seed(&x->x_seed, 0); outlet_new((t_object *)x, &s_float); x->x_bangout = outlet_new((t_object *)x, &s_bang); - x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, 0, 0); + x->x_filehandle = hammerfile_new((t_pd *)x, prob_embedhook, 0, 0, 0); return (x); } @@ -301,12 +298,10 @@ void prob_setup(void) class_addmethod(prob_class, (t_method)prob_dump, gensym("dump"), 0); /* CHECKED: doesn't understand "seed" */ - - /* below are the incompatible extensions... */ - class_addmethod(prob_class, (t_method)prob_silent, - gensym("silent"), 0); + class_addmethod(prob_class, (t_method)prob__silent, + gensym("_silent"), 0); class_addmethod(prob_class, (t_method)prob_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - hammerfile_setup(prob_class, 0); /* LATER embedding (, 1) */ + hammerfile_setup(prob_class, 1); } |