Ah, thanks so much-- this is very helpful.
Send chuck-users mailing list submissions to
chuck-users@lists.cs.princeton.edu
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
or, via email, send a message with subject or body 'help' to
chuck-users-request@lists.cs.princeton.edu
You can reach the person managing the list at
chuck-users-owner@lists.cs.princeton.edu
When replying, please edit your Subject line so it is more specific
than "Re: Contents of chuck-users digest..."
Today's Topics:
1. Re: "Or" (David M)
2. Re: "Or" (Kassen)
3. Re: "Or" (Rebecca Fiebrink)
4. Re: "Or" (Kassen)
---------- Forwarded message ----------
From: David M <fimbulwintr@gmail.com>
To: ChucK Users Mailing List <chuck-users@lists.cs.princeton.edu>
Date: Fri, 3 Sep 2010 12:02:24 -0400
Subject: Re: [chuck-users] "Or"
I believe that the much simpler way is to simply use "maybe"
float sampleRate
if (maybe)
1.0 => sampleRate;
else
1.5 => sampleRate2010/9/3 Mark Cerqueira <mark.cerqueira@gmail.com>
Tim,You can use rand2f to do this....
float sampleRate;if (std.rand2f(0.0, 1.0) < 0.5)1.0 => sampleRate;else1.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,MarkOn 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@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
--
David M
---------- Forwarded message ----------
From: Kassen <signal.automatique@gmail.com>
To: ChucK Users Mailing List <chuck-users@lists.cs.princeton.edu>
Date: Fri, 3 Sep 2010 18:04:34 +0200
Subject: Re: [chuck-users] "Or"2010/9/3 Mark Cerqueira <mark.cerqueira@gmail.com>
Tim,You can use rand2f to do this....float sampleRate;if (std.rand2f(0.0, 1.0) < 0.5)1.0 => sampleRate;else1.5 => sampleRate;
Mark is right, his code is clean, readable and correct. It could also easily be tweaked to change the distribution.... And yet I'd still be tempted to do this;1 + (.5 * maybe) => float sampleRate;Generally "maybe" is my first port of call if I want to quickly and randomly choose between two options;if (maybe) do_stuff();else do_things();Take Mark's option for long term projects that you will need to get back to or collaborate on. Pick my first option when livecoding as it's short to type and audiences like "maybe" as a word. My second expample might be closest to the PD object that you are missing. "maybe" resolves to "true" or "false" ("1"(int) and "0" (int) in ChucK) with 50/50 chance at each call. Practically speaking it's completely equivalent to;Std.rand2(0,1)However that, unlike Mark's example, can't be tuned in case you later decide you need a 25/75 distribution instead.Yours,Kas.
---------- Forwarded message ----------
From: Rebecca Fiebrink <fiebrink@princeton.edu>
To: chuck-users@lists.cs.Princeton.EDU
Date: Fri, 3 Sep 2010 12:09:53 -0400
Subject: Re: [chuck-users] "Or"OR, because it's chuck and therefore more fun than your average language:if (maybe)1.0 => sampleRate;else1.5 => sampleRate;
Message: 2
Date: Fri, 3 Sep 2010 11:21:34 -0400
From: Timothy Leonido <timothy.leonido@gmail.com>
To: chuck-users@lists.cs.princeton.edu
Subject: [chuck-users] "Or"
Message-ID:
<AANLkTikKmHj+557HnyR5wB3Mpd1owLc+D8zhwrKrFFZT@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20100903/a938743d/attachment-0001.html>
------------------------------
Message: 3
Date: Fri, 3 Sep 2010 08:46:08 -0700
From: Mark Cerqueira <mark.cerqueira@gmail.com>
To: ChucK Users Mailing List <chuck-users@lists.cs.princeton.edu>
Subject: Re: [chuck-users] "Or"
Message-ID: <7C3AA188-1842-4494-A6B5-613D133C1C9F@gmail.com>
Content-Type: text/plain; charset="us-ascii"
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
---------- Forwarded message ----------
From: Kassen <signal.automatique@gmail.com>
To: ChucK Users Mailing List <chuck-users@lists.cs.princeton.edu>
Date: Fri, 3 Sep 2010 18:29:10 +0200
Subject: Re: [chuck-users] "Or"2010/9/3 Rebecca Fiebrink <fiebrink@princeton.edu>
OR, because it's chuck and therefore more fun than your average language:Ok, that's it.Let's have "probably" and "perhaps" at 75% and 25% as well. Everyone loves "maybe" so much, we might as well have more of it.Does English have single words describing indeterminate times and/or durations that aren't already reserved or would be confusing? We talk about "in a bit" or "in a while" but those sound like they would be cause for confusion. "soon" might be a good one?Kas.
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users