[the_posthumans] Re: Varia SC3 question
- From: Mark Polishook <polishoo@xxxxxxx>
- To: the_posthumans@xxxxxxxxxxxxx
- Date: Wed, 23 Mar 2005 08:43:24 -0800
Hi Kasper,
That's a good question!
Here's what's happening -
Each time your routine fires, it evaluates whatever code it sees in the
function. In this case, the code it sees is an array that's receiving a
'wchoose' message.
So what happens is that SC evaluates the array - which consists of 3
synths. Since it sees 3 synths in the array, it simply plays them. If
you had code with
[1, 2, 3]
SuperCollider would see the numbers in the array and build an array with
[1, 2, 3]
Back to your example. The array contains
[ Synth(....), Synth(....), Synth(....)]
So SC builds the array, which means each of the Synths is evauated and
it plays. THEN, the w.choose message is sent to the array and a Synth
that is _already playing is chosen.
Obviously, this isn't what you want. :) .... what you need is
[ { Synth( ..... ) }, { Synth( ..... ) }, { Synth( ..... )
}].wchoose([...]).value
The difference here is that the array is built. SC sees it contains 3
functions. Code in functions isn't evaluated until it receives a value
message. So ...... the array is built with 3 functions. The wchoose
message selects on of them according to your weights. Once that has
been selected, the value message evaluates the function and, "det er
storartet!" (it is terrific!)
the key idea is that sc builds the array first. then it chooses an item
from the array. since the array consists, in this case, of 3 synths,
all that will happen is a synth that is already playing will be chosen.
and that synth won't be retriggered because it's already been
evaluated.
by wrapping each of the synths in a function, eg { .... }, you're
telling sc only that each item in the array is a function, that is,
code that will be evaluated only when it receives a value message. so
the array is built with 3 items, which, again, are functions. wchoose
selects one of them. and then the value message evaluates it.
on top of all this sits the question of what is the order in which
things are evaluated in sc? the answer is
1;
2;
3;
sequentially, as the code above shows
[1, 2, 3];
4;
5;
or sequentially, as the code above shows
however, this
5.someMessage(oneArgument, anotherArgument
is really equivalent to something like this
x = oneArgument;
y = anotherArgument;
5.someMessage(x, y);
with this reasoning, your example was equal to
// each of these synths will evaluate and _play
x = Synth(....);
y = Synth(...);
z = Synth(....);
a = [x, y, z];
a.wchoose([....]);
what you really wanted was this ....
x = { Synth(....) };
y = { Synth(....) };
z = { Synth(....) };
a = [x. y, z];
b = a.wchoose([....]);
b.value;
does this make sense?
On Mar 23, 2005, at 1:46 AM, .kspr wrote:
> Oh yeah - about the Varia 2 for 1 piece, I have another question which
> bugs me:
>
> (
> q = Routine({
> ("*** Choice: Event 2").postln;
> ("*****************************************************").postln;
> [Synth("organ", [\dur, [0.25, 0.5, 1, 1.5, 2.0, 2.5, 3.0].choose]),
> Synth("Highs", [\dur, [0.25, 0.5, 1, 1.5, 2.0, 2.5, 3.0].choose]),
> Synth("klcks", [\dur, [1, 2, 3, 4, 5, 6, 7].choose])].wchoose([0.50,
> 0.20, 0.30]);
> });
> )
>
> Why does the wchoose not seem to work for me? It seems that it plays
> all the synthdefs and not just settles for one of them with respect for
> the percentage distribution I chose in the wchoose..
>
> All the best,
> /.kspr
> http://kspr.pale-dawn.dk
>
> Give the robots a voice.
> Send mail to the_posthumans@xxxxxxxxxxxxx
> Subscribe/unsubscribe:
> http://www.cwu.edu/~polishoo/pmwiki/the_posthumans.html
>
Give the robots a voice.
Send mail to the_posthumans@xxxxxxxxxxxxx
Subscribe/unsubscribe: http://www.cwu.edu/~polishoo/pmwiki/the_posthumans.html
- Follow-Ups:
- [the_posthumans] Re: Varia SC3 question
- From: . kspr
- References:
- [the_posthumans] Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: . kspr
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: Mark Polishook
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: . kspr
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: Mark Polishook
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: hedgehogjazz
- [the_posthumans] Varia SC3 question
- From: . kspr
Other related posts:
- » [the_posthumans] Varia SC3 question
- » [the_posthumans] Re: Varia SC3 question
- » [the_posthumans] Re: Varia SC3 question
- » [the_posthumans] Re: Varia SC3 question
- [the_posthumans] Re: Varia SC3 question
- From: . kspr
- [the_posthumans] Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: . kspr
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: Mark Polishook
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: . kspr
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: Mark Polishook
- [the_posthumans] Re: Instant Jam Sessions @ Royal Academy Of Arts, Denmark
- From: hedgehogjazz
- [the_posthumans] Varia SC3 question
- From: . kspr