[chuck-users] Getting Started with ChucK
Tom Lieber
tom at alltom.com
Tue Jul 21 19:44:00 EDT 2009
2009/7/21 Kassen <signal.automatique at gmail.com>:
> Ok, yes, I wrote that but I like the idea of assigning UGen outputs to UGen
> member function inputs much better. For one thing it seems much more simple,
> for another it should interact better with the UGen graph's pull-through
> model and so not depend on when we start such a shred relative to where the
> sample clock might be at that moment to the same degree. It seems much more
> predictable and intuitive to me.
Definitely.
>> SinOsc b => dac;
>> { a.last(); } @=> b.freq;
>
> Ok, this I can see. My one issue with it is a fairly big one though; this
> function isn't typed.
What? b.freq needs a float so the expression on the left would need to
return a float.
>> { now < start + 5::second ? 5 : 10 } @=> a.freq;
>
> I'm really sorry but you utterly lost me here. This looks a bit like Lisp
> without the brackets. You seem to mean something like;
>
> while( now < (start + 5::seconds) )
> {
> Std.rand2(5,10) => a.freq;
> samp => now;
> }
"___ ? ___ : ___" is conditional syntax. It's an if-statement as an
expression. My lambda is like:
while(samp => now)
if(now < start + 5::second)
5 => a.freq;
else
10 => a.freq;
Or, effectively,
5 => a.freq;
5::second => now;
10 => a.freq;
The idea is that it's an example of something it's unlikely one would
bother writing a UGen to do, and is easier to write with lambda syntax
than today's ChucK.
> Yes, but if we demand those aspects of anonymous functions I would say they
> are starting to look suspiciously like UGens in how specialised they would
> be, right?
Yeah, they're little UGens. That's the idea!
> Yes, that's true, that could be done fairly easily, but that way there is no
> way of getting rid of these modulations again from within ChucK code...
> unless we allow for that with more structures, by which time it will be
> significantly more expensive on the CPU than if we'd do the same thing
> manually. All of those shreds from a single file/scope could easily be
> combined into a single shred, for example.
It wasn't an incredibly serious suggestion. :D
In ruck the lambda assignment is just that, an assignment. To
"disconnect" it you set a new value.
{ a.last() } => b.freq;
5 => b.freq;
--
Tom Lieber
http://AllTom.com/
More information about the chuck-users
mailing list