[chuck-users] "Or"

Mark Cerqueira mark.cerqueira at gmail.com
Fri Sep 3 11:46:08 EDT 2010


Tim,
You can use rand2f to do this....

float sampleRate;

if (std.rand2f(0.0, 1.0) < 0.5)
    1.0 => sampleRate;
else
    1.5 => sampleRate;

I ran this section of code 1,000,000 times in my program doing this chunk of code every 1 sample and:

1. ChucK did not make my computer explode :)
2. The rate was set to 1.0 500,814 times and 1.5 499,186 times (pretty good distribution)

Hope that helps! 

Best,
Mark

On Sep 3, 2010, at 8:21 AM, Timothy Leonido wrote:

> Hallo, 
> 
> Once again, sorry for the rudimentary questions, but I can't seem to find the correct language for a very simple function: Instead of using Std.rand2f( ) for fluctuating volume or buf.rate, I'd like to simply have an either/or option. Play sample at a rate of 1.0 or 1.5, randomly. The moses function (in pure data) was useful for this. Direction to the appropriate helpful would also be appreciated.
> 
> 
> 
> Thanks so much, 
> 
> Tim 
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20100903/00762b6b/attachment.html>


More information about the chuck-users mailing list