aboutsummaryrefslogtreecommitdiff
path: root/cyclone/sickle
diff options
context:
space:
mode:
Diffstat (limited to 'cyclone/sickle')
-rw-r--r--cyclone/sickle/peek.c8
-rw-r--r--cyclone/sickle/poke.c4
-rw-r--r--cyclone/sickle/record.c68
-rw-r--r--cyclone/sickle/sickle.c19
4 files changed, 63 insertions, 36 deletions
diff --git a/cyclone/sickle/peek.c b/cyclone/sickle/peek.c
index 534cc49..333f427 100644
--- a/cyclone/sickle/peek.c
+++ b/cyclone/sickle/peek.c
@@ -31,7 +31,7 @@ static void peek_tick(t_peek *x)
{
arsic_redraw((t_arsic *)x); /* LATER redraw only dirty channel(s!) */
x->x_clockset = 0;
- x->x_clocklasttick = clock_getsystime();
+ x->x_clocklasttick = clock_getlogicaltime();
}
static void peek_set(t_peek *x, t_symbol *s)
@@ -41,7 +41,7 @@ static void peek_set(t_peek *x, t_symbol *s)
#define peek_doclip(f) (f < -1. ? -1. : (f > 1. ? 1. : f))
-/* CHECKED refman error: ``if the number received in the left inlet
+/* CHECKED refman's error: ``if the number received in the left inlet
specifies a sample index that does not exist in the buffer~ object's
currently allocated memory, nothing happens.'' This is plainly wrong,
at least for max/msp 4.0.7 bundle: the index is clipped (just like
@@ -115,14 +115,14 @@ static void *peek_new(t_symbol *s, t_floatarg f1, t_floatarg f2)
ch = PEEK_MAXCHANNELS;
x->x_maxchannels = (ch ? PEEK_MAXCHANNELS : 1);
x->x_effchannel = x->x_reqchannel = (ch ? ch - 1 : 0);
- /* CHECKED (refman error) clipping is disabled by default */
+ /* CHECKED (refman's error) clipping is disabled by default */
x->x_clipmode = ((int)f2 != 0);
x->x_pokemode = 0;
inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1"));
inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2"));
outlet_new((t_object *)x, &s_float);
x->x_clock = clock_new(x, (t_method)peek_tick);
- x->x_clocklasttick = clock_getsystime();
+ x->x_clocklasttick = clock_getlogicaltime();
x->x_clockset = 0;
}
return (x);
diff --git a/cyclone/sickle/poke.c b/cyclone/sickle/poke.c
index d0fb22a..7e45558 100644
--- a/cyclone/sickle/poke.c
+++ b/cyclone/sickle/poke.c
@@ -29,7 +29,7 @@ static void poke_tick(t_poke *x)
{
arsic_redraw((t_arsic *)x); /* LATER redraw only dirty channel(s!) */
x->x_clockset = 0;
- x->x_clocklasttick = clock_getsystime();
+ x->x_clocklasttick = clock_getlogicaltime();
}
static void poke_set(t_poke *x, t_symbol *s)
@@ -132,7 +132,7 @@ static void *poke_new(t_symbol *s, t_floatarg f)
x->x_indexptr = fragile_inlet_signalscalar(in2);
inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2"));
x->x_clock = clock_new(x, (t_method)poke_tick);
- x->x_clocklasttick = clock_getsystime();
+ x->x_clocklasttick = clock_getlogicaltime();
x->x_clockset = 0;
}
return (x);
diff --git a/cyclone/sickle/record.c b/cyclone/sickle/record.c
index ba2e3b5..f03e784 100644
--- a/cyclone/sickle/record.c
+++ b/cyclone/sickle/record.c
@@ -8,6 +8,8 @@
#include "sickle/sic.h"
#include "sickle/arsic.h"
+#define RECORD_REDRAWPAUSE 1000. /* refractory period */
+
typedef struct _record
{
t_arsic x_arsic;
@@ -23,13 +25,20 @@ typedef struct _record
float x_syncincr;
int x_isrunning; /* to know if sync should be 0.0 or 1.0 */
t_clock *x_clock;
+ double x_clocklasttick;
} t_record;
static t_class *record_class;
static void record_tick(t_record *x)
{
- arsic_redraw((t_arsic *)x);
+ double timesince = clock_gettimesince(x->x_clocklasttick);
+ if (timesince >= RECORD_REDRAWPAUSE)
+ {
+ arsic_redraw((t_arsic *)x);
+ x->x_clocklasttick = clock_getlogicaltime();
+ }
+ else clock_delay(x->x_clock, RECORD_REDRAWPAUSE - timesince);
}
static void record_setsync(t_record *x)
@@ -37,15 +46,15 @@ static void record_setsync(t_record *x)
/* CHECKED: clipped to array size -- using indices, not points */
float range = (float)(x->x_endindex - x->x_startindex);
int phase = x->x_phase;
- if (phase == SHARED_INT_MAX || range < 1.0)
+ if (phase == SHARED_INT_MAX || range < 1.)
{
- x->x_sync = (x->x_isrunning ? 1.0 : 0); /* CHECKED */
- x->x_syncincr = 0;
+ x->x_sync = (x->x_isrunning ? 1. : 0.); /* CHECKED */
+ x->x_syncincr = 0.;
}
else
{
x->x_sync = (float)(phase - x->x_startindex) / range;
- x->x_syncincr = 1.0 / range;
+ x->x_syncincr = 1. / range;
}
}
@@ -68,6 +77,15 @@ static void record_set(t_record *x, t_symbol *s)
record_mstoindex(x);
}
+static void record_reset(t_record *x)
+{
+ x->x_startpoint = x->x_endpoint = 0.;
+ x->x_pauseindex = SHARED_INT_MAX;
+ x->x_phase = SHARED_INT_MAX;
+ x->x_isrunning = 0;
+ record_mstoindex(x);
+}
+
static void record_startpoint(t_record *x, t_floatarg f)
{
x->x_startpoint = f;
@@ -91,7 +109,7 @@ static void record_float(t_record *x, t_float f)
}
else if (x->x_phase != SHARED_INT_MAX) /* CHECKED: no rewind */
{
- record_tick(x);
+ clock_delay(x->x_clock, 10.);
x->x_pauseindex = x->x_phase;
x->x_phase = SHARED_INT_MAX;
}
@@ -126,7 +144,7 @@ static t_int *record_perform(t_int *w)
{
int vecsize = sic->s_vecsize;
float syncincr = x->x_syncincr;
- int ch, over, i, nxfer;
+ int ch, over, i, nxfer, ndone = 0;
loopover:
if ((nxfer = endphase - phase) > nblock)
{
@@ -140,7 +158,7 @@ loopover:
t_float *vp = sic->s_vectors[ch];
if (vp)
{
- t_float *ip = (t_float *)(w[3 + ch]);
+ t_float *ip = (t_float *)(w[3 + ch]) + ndone;
vp += phase;
i = nxfer;
/* LATER consider handling under and overflows */
@@ -148,6 +166,10 @@ loopover:
}
}
i = nxfer;
+
+ sync = phase;
+ syncincr = 1.;
+
while (i--)
{
*out++ = sync;
@@ -155,31 +177,35 @@ loopover:
}
if (over)
{
+ clock_delay(x->x_clock, 0);
nblock -= nxfer;
if (x->x_loopmode
&& (phase = x->x_startindex) < endphase)
{
x->x_phase = phase;
x->x_sync = sync = 0;
- if (nblock > 0) goto loopover;
- goto done;
+ if (nblock > 0)
+ {
+ ndone += nxfer;
+ goto loopover;
+ }
+ goto alldone;
}
- clock_delay(x->x_clock, 0);
/* CHECKED: no restart in append mode */
x->x_pauseindex = SHARED_INT_MAX;
x->x_phase = SHARED_INT_MAX;
- x->x_sync = 1.0;
- x->x_syncincr = 0;
+ x->x_sync = 1.;
+ x->x_syncincr = 0.;
}
else
{
x->x_phase += nxfer;
x->x_sync = sync;
- goto done;
+ goto alldone;
}
}
- while (nblock--) *out++ = sync;
-done:
+ while (nblock--) *out++ = -1; //sync;
+alldone:
return (w + sic->s_nperfargs + 1);
}
@@ -203,15 +229,11 @@ static void *record_new(t_symbol *s, t_floatarg f)
{
int nch = arsic_getnchannels((t_arsic *)x);
arsic_setminsize((t_arsic *)x, 2);
- x->x_startpoint = 0;
- x->x_endpoint = 0;
x->x_appendmode = 0;
x->x_loopmode = 0;
- x->x_pauseindex = SHARED_INT_MAX;
- x->x_phase = SHARED_INT_MAX;
- x->x_isrunning = 0;
- record_mstoindex(x);
+ record_reset(x);
x->x_clock = clock_new(x, (t_method)record_tick);
+ x->x_clocklasttick = clock_getlogicaltime();
while (--nch)
inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal);
inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft-2"));
@@ -239,4 +261,6 @@ void record_tilde_setup(void)
gensym("loop"), A_FLOAT, 0);
class_addmethod(record_class, (t_method)record_set,
gensym("set"), A_SYMBOL, 0);
+ class_addmethod(record_class, (t_method)record_reset,
+ gensym("reset"), 0);
}
diff --git a/cyclone/sickle/sickle.c b/cyclone/sickle/sickle.c
index 765209a..8df7974 100644
--- a/cyclone/sickle/sickle.c
+++ b/cyclone/sickle/sickle.c
@@ -27,21 +27,24 @@ static void sickle_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av)
import_max(fn->s_name, "");
}
-static void sickle_import(t_sickle *x, t_symbol *fn, t_symbol *dir)
+static void sickle_doimport(t_sickle *x, t_symbol *fn, t_symbol *dir)
{
+ if (!dir || dir == &s_) dir = x->x_dir;
if (fn && fn != &s_)
- {
- if (!dir || dir == &s_) dir = x->x_dir;
import_max(fn->s_name, (dir && dir != &s_) ? dir->s_name : "");
- }
else
- hammerpanel_open(x->x_filehandle);
+ hammerpanel_open(x->x_filehandle, dir);
}
static void sickle_click(t_sickle *x, t_floatarg xpos, t_floatarg ypos,
- t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ sickle_doimport(x, 0, 0);
+}
+
+static void sickle_import(t_sickle *x, t_symbol *fn)
{
- sickle_import(x, 0, 0);
+ sickle_doimport(x, fn, 0);
}
static void sickle_bang(t_sickle *x)
@@ -82,7 +85,7 @@ void sickle_setup(void)
sizeof(t_sickle), 0, A_DEFSYM, 0);
class_addbang(sickle_class, sickle_bang);
class_addmethod(sickle_class, (t_method)sickle_import,
- gensym("import"), A_DEFSYM, A_DEFSYM, 0);
+ gensym("import"), A_DEFSYM, 0);
class_addmethod(sickle_class, (t_method)sickle_click,
gensym("click"),
A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);