[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] BooleanUGens (was Re: conditional statement in SynthDef)
On Sep 4, 2005, at 4:50 PM, Joshua Parmenter wrote:
Hi everyone,
After talking to Dan a little bit, I decided to make a few quick UGens that do some basic Boolean stuff. They return 0 for false, 1 for true. There is:
IsEqual, IsNotEqual, IsLess, IsLessOrEqual, IsGreater, IsGreaterOrEqual
I don't think there is a need for new UGens. BinaryOpUGens.cpp already implements opEQ and opNE:
<x-tad-smaller>s.boot;
a = { </x-tad-smaller><x-tad-smaller>|a = 0, b = 0|</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>Impulse</x-tad-smaller><x-tad-smaller>.kr(1), 0, </x-tad-smaller><x-tad-smaller>'=='</x-tad-smaller><x-tad-smaller>, a, b))
}.play
o = </x-tad-smaller><x-tad-smaller>OSCresponderNode</x-tad-smaller><x-tad-smaller>(s.addr, </x-tad-smaller><x-tad-smaller>'/tr'</x-tad-smaller><x-tad-smaller>, { </x-tad-smaller><x-tad-smaller>|t, r, m|</x-tad-smaller><x-tad-smaller> m.postln }).add;
a.set(</x-tad-smaller><x-tad-smaller>\a</x-tad-smaller><x-tad-smaller>, 1);
a.free;
o.remove;
</x-tad-smaller>
So the issue is merely that AbstractFunction doesn't implement == and != -- why could UGen not simply implement those two operators?
So IsEqual requires no c code, just:
IsEqual {
*kr { |a, b|
BinaryOpUGen('==', a, b)
}
}
Or, is that how you did it, Josh? Haven't downloaded the pack.
hjh
: 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