On Tue, Jun 16, 2009 at 10:55 PM, James Harkins
<jamshark70@xxxxxxxxx> wrote:
"if(condition, { true }, { false })" evaluates either the true or false branch once, at the time the SynthDef is compiled. Then the result is hardcoded into the SynthDef.
ah... I get it. That's what is meant by "inlining" isn't?.... the if condition is just executed once when the compiler creates the executable code .. and the result is then hard coded into that executable compiled synthdef ... which explains why I always get the same result.
For that to happen, the Boolean value of the condition has to be known when the SynthDef is compiled. But the condition depends on values that don't exist until the Synth is played. By wrapping true and false in functions, you're inadvertently asking the language to evaluate a condition now for values to be calculated later, which is impossible.
BinaryOpUGen('==', doppler, 1) is not a Boolean -- it's a signal that will be 0 for false and 1 for true. You can use this with if, but as noted in the earlier post, if you do that, the true and false branches must both be signals, not functions or any other kind of object.
So, take out the curly braces :)
...AHA ! ... I see. I see two things now (my pea is getting bigger). I see that curly brackets means a function (ok, I should have known that). So the following will work because the two branches are signals.
var audioOutput = if ( BinaryOpUGen('==', 1, doppler), DelayL.ar( air_attenuated_input, maxDelayTime , delayTime ) , air_attenuated_input );
The second thing I see is that I have an other if condition that involves control messages:
var aziD = if (doppler == 1, { DelayL.kr( azi_smoothed , maxDelayTime , delayTime ) }, {azi_smoothed});
On Jun 16, 2009, at 8:28 AM, e deleflie wrote:
Hi James,
yeah, that's the post I was referring to that I read .... unfortunately for my pea sized brain, it was just too much ... I thought I'd understood from that post that all I needed to do was use:
BinaryOpUGen('==', doppler, 1)
but that just creates an "ERROR: Non Boolean in test."
Etienne
On Tue, Jun 16, 2009 at 10:20 PM, James Harkins
<jamshark70@xxxxxxxxx> wrote:
Perennial topic - I wrote a bedtime story about it once :)
(You're still writing if(condition, { true }, { false }) which is not valid inside a SynthDef.)
: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman