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

Re: [sc-users] BooleanUGens (was Re: conditional statement in SynthDef)



On Sep 5, 2005, at 1:04 PM, Joshua Parmenter wrote:

I first tried to add ==, but a recompile of the library threw all sorts of errors. It seemed to me that, at least on a first look , adding == as a UGen would break code. I really didn't spend much time trying different approaches. It seemed like it would be very simple to code in C, so IsEqual made sense to me.

Here is the problem. There may be an alternate way to handle it, but it could be risky.

Maybe a.asFloat === 0.0 etc.? But that would create and throw out a bunch of objects for UGens. Maybe have testA = a.asFloat; testB = b.asFloat;

Dunno, maybe it's not worth it. Since BinaryOpUGen already supports == and != I think it could just be documented how to write the BinaryOpUGen yourself. Or implement IsEqual in terms of BinaryOpUGen. I don't think we need to lard it up with more plugins for things already included in the plugin lib.

hjh

<x-tad-smaller> if (selector == </x-tad-smaller><x-tad-smaller>'*'</x-tad-smaller><x-tad-smaller>, {
if (a == 0.0, { ^0.0 });
if (b == 0.0, { ^0.0 });
if (a == 1.0, { ^b });
if (a == -1.0, { ^b.neg });
if (b == 1.0, { ^a });
if (b == -1.0, { ^a.neg });
},{
if (selector == </x-tad-smaller><x-tad-smaller>'+'</x-tad-smaller><x-tad-smaller>, {
if (a == 0.0, { ^b });
if (b == 0.0, { ^a });
},{
if (selector == </x-tad-smaller><x-tad-smaller>'-'</x-tad-smaller><x-tad-smaller>, {
if (a == 0.0, { ^b.neg });
if (b == 0.0, { ^a });
},{
if (selector == </x-tad-smaller><x-tad-smaller>'/'</x-tad-smaller><x-tad-smaller>, {
if (b == 1.0, { ^a });
if (b == -1.0, { ^a.neg });
if (b.rate == </x-tad-smaller><x-tad-smaller>'scalar'</x-tad-smaller><x-tad-smaller>, { ^a * b.reciprocal });
})})})});
</x-tad-smaller>


: H. James Harkins
: jamshark70@xxxxxxxxxxxxxxxxx
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman