[PD-dev] using rand() in an external

Greg Surges surgesg at gmail.com
Mon Mar 17 00:42:50 CET 2008


Hi all,

The following code crashes Pd when the randomwalk object receives a bang...
I'm stuck as to why, can anyone see a reason?
void randomwalk_bang(t_randomwalk *x)
{
    t_float randval = rand() % 2;
    if(randval == 0) randval = -1;
    if(randval == 1) randval = 1;
    x->current += (x->step * randval);
    outlet_float(x->f_out, x->current);
}

Thanks in advance,

-Greg

-- 
http://www.uwm.edu/~gssurges/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20080316/36e86a48/attachment.htm>


More information about the Pd-dev mailing list