[PD-dev] getting Pd logical time in C
Miller Puckette
mpuckett at imusic1.ucsd.edu
Sat Jun 3 02:24:24 CEST 2006
Oh... I get it. For that, the function is ugen_getsortno() -- returns
an integer which increases eachtime DSP is restarted. You can add the
function call (to the ugen chain for instance) each time you see
ugen_getsortno() return an integer greater than the previous one you've
seen.
cheers
Miller
On Sat, Jun 03, 2006 at 12:26:00AM +0200, Hans-Christoph Steiner wrote:
>
> I guess I should really post some example code:
>
> int timestamp;
>
> hid_get_events(x)
> {
> // fill an array with the data that I get
> }
>
> hid_read(x)
> {
> int right_now = get_logical_time();
> if(right_now > timestamp)
> hid_get_events_into_array(x);
> hid_output_events_from_array(x);
> }
>
> .hc
>
> On Jun 3, 2006, at 12:21 AM, Hans-Christoph Steiner wrote:
>
> >
> >Actually, I think logical time would work perfectly for what I am
> >trying to do. I want to have the first instance that is executed
> >in any given cycle run a function, but none of the rest. As far as
> >I understand, the instance that is created first is not necessarily
> >the first one to execute in each cycle.
> >
> >So if I run the function, then set a global variable to the logical
> >time, then next instance would check the logical time against that
> >global variable. If it was equal, it would skip that function.
> >That should guarantee that the first instance to execute in a given
> >cycle will execute that function, rather than just using instance 0.
> >
> >Any comments or suggestions appreciated, as usual. So... how do I
> >get the logical time? Time to dig...
> >
> >.hc
> >
> >On May 19, 2006, at 5:02 PM, Miller Puckette wrote:
> >
> >>Logical time wouldn't work for that, as two objects in the same
> >>patch are
> >>created at teh same logical time. I'd suggest code like:
> >>
> >>{
> >> static int initted = 0;
> >> if (!initted)
> >> {
> >> .. this code only runs once ..
> >> initted = 1;
> >> }
> >>}
> >>
> >>cheers
> >>M
> >>
> >>On Fri, May 19, 2006 at 11:37:45AM +0200, Hans-Christoph Steiner
> >>wrote:
> >>>
> >>>I want to get the logical time so I can make the first instance of
> >>>the object execute something while the rest do not execute.
> >>>
> >>>Any suggestions as how to do this?
> >>>
> >>>.hc
> >>>
> >>>____________________________________________________________________
> >>>____
> >>>____
> >>>
> >>>If you are not part of the solution, you are part of the problem.
> >>> -
> >>>Eldridge Cleaver
> >>>
> >>>
> >>>_______________________________________________
> >>>PD-dev mailing list
> >>>PD-dev at iem.at
> >>>http://lists.puredata.info/listinfo/pd-dev
> >
> >
> >______________________________________________________________________
> >______
> >
> >If you are not part of the solution, you are part of the problem.
> > -
> >Eldridge Cleaver
> >
>
>
> ________________________________________________________________________
> ____
>
> "Computer science is no more related to the computer than astronomy
> is related to the telescope."
> -Edsger
> Dykstra
>
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev
More information about the Pd-dev
mailing list