From faada59567f8cb252f4a909116595ce309ff5828 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Fri, 23 May 2003 12:29:55 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r647, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/miXed/; revision=648 --- cyclone/hammer/next.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 cyclone/hammer/next.c (limited to 'cyclone/hammer/next.c') diff --git a/cyclone/hammer/next.c b/cyclone/hammer/next.c new file mode 100644 index 0000000..3fe7d6e --- /dev/null +++ b/cyclone/hammer/next.c @@ -0,0 +1,58 @@ +/* Copyright (c) 2002-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. */ + +#include "m_pd.h" + +//#define NEXT_USEEVENTNO + +typedef struct _next +{ + t_object x_ob; +#ifdef NEXT_USEEVENTNO + int x_lastevent; +#else + double x_lastevent; +#endif + t_outlet *x_out2; +} t_next; + +static t_class *next_class; + +/* CHECKME first call, CHECKME if the outlets are not swapped */ +static void next_anything(t_next *x, t_symbol *s, int ac, t_atom *av) +{ +#ifdef NEXT_USEEVENTNO + int nextevent = sys_geteventno(); +#else + double nextevent = clock_getlogicaltime(); +#endif + if (x->x_lastevent == nextevent) + outlet_bang(x->x_out2); + else + { + x->x_lastevent = nextevent; + outlet_bang(((t_object *)x)->ob_outlet); + } +} + +static void *next_new(void) +{ + t_next *x = (t_next *)pd_new(next_class); + outlet_new((t_object *)x, &s_bang); + x->x_out2 = outlet_new((t_object *)x, &s_bang); +#ifdef NEXT_USEEVENTNO + x->x_lastevent = sys_geteventno(); +#else + x->x_lastevent = clock_getlogicaltime(); +#endif + return (x); +} + +void next_setup(void) +{ + next_class = class_new(gensym("next"), + (t_newmethod)next_new, 0, + sizeof(t_next), 0, 0); + class_addanything(next_class, next_anything); +} -- cgit v1.2.1