[PD] [epochtime] - my first external

David Sabine dave at davesabine.com
Wed Nov 20 04:16:48 CET 2002


Hello,

If I switch those two lines around, then I get an error when compiling the
external.  'f' : undeclared identifier

but Thanks for your reponse...

Regards,
Dave S


----- Original Message -----
From: "Rua Haszard Morris" <ruahm at yahoo.com>
To: "David Sabine" <dave at davesabine.com>
Sent: Tuesday, November 19, 2002 9:07 PM
Subject: Re: [PD] [epochtime] - my first external


> OK I know nuthin of externals.. but...
>
> > void epochtime_bang(t_epochtime *x)
> > {
> >   t_float f=x->t;
> >   x->t=time( NULL );
> >
> >   outlet_float(x->x_obj.ob_outlet, f);
> > }
>
> here, on bang 1, you output whatever is in x->t (the
> init value or unused memory or whatever), and then set
> the x->t value to the current time.
>
> Then on bang 2, you output that time (from the
> previous bang), and save the current time in x->t (for
> next time).
>
> try this..
>
> > void epochtime_bang(t_epochtime *x)
> > {
> >   x->t=time( NULL ); // get the time & sto' in x->t
> >   t_float f=x->t; // retrieve that value to be
> returned
> >
> >   outlet_float(x->x_obj.ob_outlet, f);
> > }
>
>
> --- David Sabine <dave at davesabine.com> wrote: > Hello
> all,
> >
> > I'm exploring my very first external!   But I've run
> > into a snag.
> >
> > I'd like to build an external object which outputs
> > the number of seconds since "epoch" when banged.
> > Epoch is the beginning of time as the digital world
> > understands it: jan 1 1970.
> >
> > Could somebody look over the following code and tell
> > me why it works only after the FIRST BANG?
> >
> > Many thanks
> > Regards,
> > Dave S
> >
> >
> > _____________________________
> >
> >
> > #include "m_pd.h"
> > #include "time.h"
> >
> > static t_class *epochtime_class;
> >
> > typedef struct _epochtime {
> >   t_object  x_obj;
> >   time_t t;
> > } t_epochtime;
> >
> > void epochtime_bang(t_epochtime *x)
> > {
> >   t_float f=x->t;
> >   x->t=time( NULL );
> >
> >   outlet_float(x->x_obj.ob_outlet, f);
> > }
> >
> > void *epochtime_new(t_floatarg f)
> > {
> >   t_epochtime *x = (t_epochtime
> > *)pd_new(epochtime_class);
> >
> >   x->t=f;
> >   outlet_new(&x->x_obj, &s_float);
> >
> >   return (void *)x;
> > }
> >
> > void epochtime_setup(void) {
> >   epochtime_class = class_new(gensym("epochtime"),
> >         (t_newmethod)epochtime_new,
> >         0, sizeof(t_epochtime),
> >         CLASS_DEFAULT, 0);
> >
> >   class_addbang(epochtime_class, epochtime_bang);
> > }
>
> =====
> Rua Haszard Morris
> Software Engineer & Research Assistant
> MARCS Auditory Laboratories
> http://www.uws.edu.au/marcs/
>
> http://www.yahoo.promo.com.au/hint/ - Yahoo! Hint Dropper
> - Avoid getting hideous gifts this Christmas with Yahoo! Hint Dropper!
>






More information about the Pd-list mailing list