Just to follow up with the solution I've arrived at:
SynthDef("flute", {arg freq = 55, sig = 65;
var freq1 = In.kr(freq);
var cutoff_freq1 = 300;
var wave = Mix.fill(5,[
SinOsc.ar(freq1)*(-1),
SinOsc.ar(freq1*2)*0.5,
{Select.ar(freq1 >= cutoff_freq1, [SinOsc.ar(freq1*3) * (-0.125), SinOsc.ar(freq1*3) * (-0.05)])},
{Select.ar(freq1 >= cutoff_freq1, [SinOsc.ar(freq1*4) * 0.02, SinOsc.ar(freq1*4) * 0.08])},
SinOsc.ar(freq1*5) * (-0.333)]);
Out.ar(sig, Mix.ar(wave/20));
}).writeDefFile(~dir);
So, I've gotten rid of the loop since it was mainly the first 5 harmonics and just put them into a mix manually. I'm not completely happy with the frequency curve yet, but that's just a matter of tweaking the parameters. I'll probably end up using SelectX instead of Select since I'm pretty sure there will be more cutoffs as I refine it. Thanks for the help!
Regards,
Bill
On Wed, Mar 24, 2021, at 10:17 PM, [email protected] wrote:
> Thanks for the link and the explanation! I can see I've got more to learn.
>
> Regards,
> Bill
>
> On Wed, Mar 24, 2021, at 7:36 PM, [email protected] wrote:
> > 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/
> >
>
> _______________________________________________
> 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/
>
_______________________________________________
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.