Comparing UGen output using conditionals

I’m trying to implement a pitch detection system, and one of the things I want to do is compare the UGen output from to an existing frequency.
Here is some sample code I’ve tried. The idea is that when the second bin of outputs 1 (i.e. it has detected a pitch), the resulting pitch will be polled. Otherwise nothing will be output.
However, I’m not getting any output. Any ideas what I’m overlooking? I’ve already tried comparing the UGen output to the number 1, and this attempt compares it to the output of a that is always set to 1. Neither of these seem to work.

    var sig, pitchSig, currentPitch, triggerComp;
    currentPitch = 0;
    sig =\;
    triggerComp =, 1, inf);
    pitchSig =;
    if(pitchSig[1] == triggerComp, {

Sadly if statements don’t work inside SynthDefs (see User FAQ | SuperCollider 3.12.2 Help)

this line: ( pitchSig[0] * pitchSig[1] ).poll;

will display the pitch (if detected) and 0 otherwise…

…but to do exactly what you ask have a look at SendTrig: SendTrig | SuperCollider 3.12.2 Help

1 Like