Update of /cvsroot/pure-data/externals/miXed/cyclone/hammer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29556/cyclone/hammer
Modified Files: seq.c Log Message: cyclone alpha55 (see notes.txt for cyclone and shared)
Index: seq.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/seq.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** seq.c 12 Mar 2005 00:19:09 -0000 1.11 --- seq.c 21 Nov 2005 22:16:37 -0000 1.12 *************** *** 27,30 **** --- 27,35 ---- #define SEQ_MINTICKDELAY 1. /* LATER rethink */ #define SEQ_TICKEPSILON ((double).0001) + #define SEQ_STARTEPSILON .0001 /* if inside: play unmodified */ + #define SEQ_TEMPOEPSILON .0001 /* if inside: pause */ + + #define SEQ_ISRUNNING(x) ((x)->x_prevtime > (double).0001) + #define SEQ_ISPAUSED(x) ((x)->x_prevtime <= (double).0001)
enum { SEQ_IDLEMODE, SEQ_RECMODE, SEQ_PLAYMODE, SEQ_SLAVEMODE }; *************** *** 286,290 **** else { /* 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; --- 291,295 ---- else { /* CHECKED timescale change */ ! if (SEQ_ISRUNNING(x)) x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; *************** *** 430,434 **** clock_delay(x->x_slaveclock, elapsed); seq_settimescale(x, (float)(elapsed * (SEQ_TICKSPERSEC / 1000.))); ! if (x->x_prevtime > 0.) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); --- 435,439 ---- clock_delay(x->x_slaveclock, elapsed); seq_settimescale(x, (float)(elapsed * (SEQ_TICKSPERSEC / 1000.))); ! if (SEQ_ISRUNNING(x)) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); *************** *** 517,521 **** static void seq_start(t_seq *x, t_floatarg f) { ! if (f < 0) { /* FIXME */ --- 522,526 ---- static void seq_start(t_seq *x, t_floatarg f) { ! if (f < -SEQ_STARTEPSILON) { /* FIXME */ *************** *** 524,528 **** else { ! seq_settimescale(x, (f == 0 ? 1. : 1024. / f)); seq_setmode(x, SEQ_PLAYMODE); /* CHECKED 'start' stops recording */ } --- 529,533 ---- else { ! seq_settimescale(x, (f > SEQ_STARTEPSILON ? 1024. / f : 1.)); seq_setmode(x, SEQ_PLAYMODE); /* CHECKED 'start' stops recording */ } *************** *** 563,568 **** warned = 1; } ! if (x->x_mode == SEQ_PLAYMODE && ! x->x_prevtime > 0.) /* running state */ { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); --- 568,572 ---- warned = 1; } ! if (x->x_mode == SEQ_PLAYMODE && SEQ_ISRUNNING(x)) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); *************** *** 582,587 **** warned = 1; } ! if (x->x_mode == SEQ_PLAYMODE && ! x->x_prevtime <= 0.) /* pause state */ { if (x->x_clockdelay < 0.) --- 586,590 ---- warned = 1; } ! if (x->x_mode == SEQ_PLAYMODE && SEQ_ISPAUSED(x)) { if (x->x_clockdelay < 0.) *************** *** 604,609 **** 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) --- 607,612 ---- t_seqevent *ev; int ndx, nevents = x->x_nevents; ! double ms = (double)f1 * 1000. + f2, sum; ! if (ms <= SEQ_TICKEPSILON) ms = 0.; if (x->x_mode != SEQ_PLAYMODE) *************** *** 625,629 **** if (x->x_clockdelay < 0.) x->x_clockdelay = 0.; ! if (x->x_prevtime > 0.) /* running state */ { clock_delay(x->x_clock, x->x_clockdelay); --- 628,632 ---- if (x->x_clockdelay < 0.) x->x_clockdelay = 0.; ! if (SEQ_ISRUNNING(x)) { clock_delay(x->x_clock, x->x_clockdelay); *************** *** 650,658 **** 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); --- 653,669 ---- double ms, clockdelay = x->x_clockdelay; t_float f1, f2; ! if (SEQ_ISRUNNING(x)) clockdelay -= clock_gettimesince(x->x_prevtime); ms = x->x_nextscoretime - clockdelay / x->x_timescale; ! /* Send ms as a pair of floats (f1, f2) = (coarse in sec, fine in msec). ! Any ms may then be exactly reconstructed as (double)f1 * 1000. + f2. ! Currently, f2 may be negative. LATER consider truncating f1 so that ! only significant digits are on (when using 1 ms resolution, a float ! stores only up to 8.7 minutes without distortion, 100 ms resolution ! gives 14.5 hours of non-distorted floats, etc.) */ ! f1 = ms * .001; ! f2 = ms - (double)f1 * 1000.; ! if (f2 < .001 && f2 > -.001) ! f2 = 0.; SETFLOAT(&aout[0], f1); SETFLOAT(&aout[1], f2); *************** *** 661,664 **** --- 672,692 ---- }
+ static void seq_tempo(t_seq *x, t_floatarg f) + { + static int warned = 0; + if (fittermax_get() && !warned) + { + fittermax_warning(*(t_pd *)x, "'tempo' not supported in Max"); + warned = 1; + } + if (f > SEQ_TEMPOEPSILON) + { + seq_settimescale(x, 1. / f); + if (x->x_mode == SEQ_PLAYMODE) + seq_startplayback(x, 0); + } + /* FIXME else pause, LATER reverse playback if (f < -SEQ_TEMPOEPSILON) */ + } + static void seq_cd(t_seq *x, t_symbol *s) { *************** *** 1207,1210 **** --- 1235,1240 ---- class_addmethod(seq_class, (t_method)seq_scoretime, gensym("scoretime"), A_SYMBOL, 0); + class_addmethod(seq_class, (t_method)seq_tempo, + gensym("tempo"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_cd, gensym("cd"), A_DEFSYM, 0);