[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] inlining in Synth Defs



It'll be evaluated immediately.

It's helpful to understand why. Ask yourself: "who" is it that is
responding to the sqrt message in your code? It must be some object
that gets passed the sqrt message.

If you type sqrt and use Cmd+Y (on mac, at least) then you see a list
of the different types of object that can respond to "sqrt". This
includes (among others) SimpleNumber and AbstractFunction. If you were
to look at the actual implementations, you'd see they do different
things, although the code gets a bit gnarly so it's not immediately
obvious what. The SimpleNumber:sqrt code calls a primitive which
simply performs the square root and returns the value. The
AbstractFunction:sqrt returns a square-rooting function. Since UGen is
a subclass of AbstractFunction, that's what you get if you call .sqrt
on a UGen, and this is what allows the .sqrt message to become "live"
in the synth.

So if you ever call sqrt on a SimpleNumber, the only thing it can
*ever* do is return a number, it can't return a UGen or anything else.
It must be evaluated immediately. In your code, it's the number
resulting from 35/8 who responds to the sqrt message.

HTH
Dan


2009/6/18 e deleflie <edeleflie@xxxxxxxxx>:
> All
>
> Will the "sqrt(35/8)" in the following line (in a synth def) be inlined?...
> or evaluated at compile time?
>
>         var x30 = cos(3 * aziD) * sqrt(35/8)  * eleD.cos.cos.cos;
>
> if not, is there a way to do it? (aziD and eleD are just local variables,
> but x30 gets multiplied to an audio signal)
>
> Etienne
>
>
>



-- 
http://www.mcld.co.uk

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/