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
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@iem.at http://lists.puredata.info/listinfo/pd-dev
Hallo!
So you mean something like a singleton-pattern? Frank posted a (non-C) solution for that some time ago on the list ... (the thread was called "Symbols and Singletons")
LG Georg
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@iem.at http://lists.puredata.info/listinfo/pd-dev
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
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@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
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@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
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@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@iem.at http://lists.puredata.info/listinfo/pd-dev