Re: varying a synthdef with respect to input frequency
| Newsgroups | gmane.comp.audio.supercollider.user |
|---|---|
| Message-ID | <CAFniQ7XyHCao2nh=zNqna6iysLa7vWhWi90219W-x_Wm5HuxBw@mail.gmail.com> |
On Thu, Mar 25, 2021 at 5:36 AM <[email protected]> wrote: > And given the values of freq and cutoff, it prints 200. What I want is to be able to do the same kind of comparison, but on a control signal, but this doesn't compile (if that's the right term). The only difference is that freq and cutoff are now control signals. > ( var freq = DC.kr(300); var cutoff = DC.kr(310); z = if (freq > cutoff, 100, 200); z.postln; ) Pressed for time at the moment, so, short answer: read this -- https://supercollider.github.io/tutorials/If-statements-in-a-SynthDef.html "The only difference is that freq and cutoff are now control signals." That isn't the only difference. It means that 300 and 310 now exist in the server only. The true and false functions are *language* constructs. They don't know the server values. Also, postln is for language side values. If you use the UGen-if-interpolation style, you'd get: ( var freq = DC.kr(300); var cutoff = DC.kr(310); z = if (freq > cutoff, 100, 200); z.postln; ) -> a BinaryOpUGen <<== this is telling you it's a server thing ( { var trig = Impulse.kr(0); var freq = DC.kr(300); var cutoff = DC.kr(310); var z = if (freq > cutoff, 100, 200); // z.postln; nope Poll.kr(trig, z); Silent.ar(1) }.play; ) UGen(BinaryOpUGen): 200 *But* when you have a lot of these, I think my suggestion will be more efficient. hjh _______________________________________________ sc-users mailing list info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx archive: http://www.listarc.bham.ac.uk/marchives/sc-users/ search: http://www.listarc.bham.ac.uk/lists/sc-users/search/