[PD] [epochtime] - my first external

David Sabine dave at davesabine.com
Wed Nov 20 06:49:31 CET 2002


Hello all,

I succeeded actually using a slightly different approach as you can see in
the following source code:  Instead of storing the number in a variable, I
decided to put the time(NULL) function directly into the outgoing argument
to the outlet.

In any case, I don't think this object will be of any use to anybody because
PD returns the following number: 1.03777e+009 (or something like it) which
can't be used very reliably.  I mean it works, but I can't see the seconds
pass -- i can only observe the passage of time every 64 seconds or so.
(What I mean is that the object will output the same number for about 64
seconds, then it outputs another number which is slightly higher.)

Perhaps Miller has an answer to this?  I know that the floating point values
in PD are limited to a specific range -- is that the cause of this
phenomenon.?

I attached the compiled external and a "epochtime_test.pd" if you want to
witness this for yourself.

Regards,
Dave S


p.s.: What I'm REALLY trying to do is put together a "difftime()" type of
routine.  But this "epochtime" seemed simpler and a logical place to begin.

________________________


#include "m_pd.h"
#include "time.h"

static t_class *epochtime_class;

typedef struct _epochtime {
  t_object  x_obj;
} t_epochtime;

void *epochtime_new(void)
{
  t_epochtime *x = (t_epochtime *)pd_new(epochtime_class);

  outlet_new(&x->x_obj, &s_float);

  return (x);
}

void epochtime_bang(t_epochtime *x)
{
  outlet_float(x->x_obj.ob_outlet, (t_float) (time( NULL )));
}

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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: epochtime_test.pd
Type: application/octet-stream
Size: 791 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20021119/c280b0c2/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: epochtime.dll
Type: application/x-msdownload
Size: 40960 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20021119/c280b0c2/attachment.bin>


More information about the Pd-list mailing list