« Return to Thread: newbie problem with SynthDefs, args and OuputProxies

Re: newbie problem with SynthDefs, args and OuputProxies

by Charlie Roberts-2 :: Rate this Message:

Reply to Author | View in Thread

Thanks! I'm starting to get the distinction better between the client / server stuff... I will try out your suggestions. The reason I was using Routine was primarily to get some timing using wait, but I understand now that the timing would have to come from the client. 

Thanks again. - Charlie

On Wed, May 7, 2008 at 3:41 AM, Dan Stowell <danstowell@...> wrote:
Hi -

OK, there's an important problem with the code you posted. Inside a
SynthDef's function you're supposed to be defining things that the
synthesis server should do. It's OK to use various language constructs
since many of them compile down to something that the server can use.

However, creating a Routine and playing it on SystemClock doesn't
belong in a SynthDef, because they're client-side things concerned
with the client-side timing. They can't be compiled down for the
synthesis server to make sense of.

You can probably use the "Phasor" UGen to create the left-to-right
ramp that you're after. You can probably also use a combination of
.abs (gives absolute value) and .sign (gives +1 for positive, -1 for
negative) to cut the "if" out of the picture altogether and write it
as a single expression.

It's a slightly different way of thinking about it but hopefully you
can put those together into something useful.

It's often OK to use "if" inside a SynthDef but not quite the way you
did it, you should use

 panPosition = if(startPan <= endPan, expr1, expr2)

rather than trying to put the "panPosition = " assignment inside. The
reason is kind of subtle, it's because inside SynthDefs we're defining
a fixed network of units rather than a set of instructions to be
run-or-not-run.

HTH
Dan



2008/5/7 Charlie Roberts <bigbadotis@...>:
> Hello everyone,
>
> I have the following SynthDef that refuses to compile; I receive an error
> message that the condition of the if statement will not return a Boolean:
>
> var patterDef = SynthDef("patterSynth", {
>  arg repeatNumber = 30, patterLength = 0.01, startPan = -1, endPan = 1;
>
>  repeatNumber.do({
>  arg a;
>  var panPosition = 0;
>
>
>
>  r = Routine.new({
>  if(startPan <= endPan,
>  { panPosition = startPan + (a * ((endPan - startPan) / repeatNumber)) },
>  { panPosition = startPan - (a * ((startPan - endPan) / repeatNumber)) }
>  )
>
>
>  /* non relevant code removed from here */
>  });
>
>
>  SystemClock.play(r);
>  });
>
>
>  }).load(s);
>
> startPan and endPan are OutputProxies; is there a way to compare them using
> their default values? I tried a combo of min and === to no avail as well...
>
> I think i'm missing something conceptually here, but I'm not sure what it
> is. Any help is appreciated... thanks! - Charlie
> _______________________________________________
>  sc-users mailing list
>  sc-users@...
>  http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>
>



--
http://www.mcld.co.uk
_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users


_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users

 « Return to Thread: newbie problem with SynthDefs, args and OuputProxies

LightInTheBox - Buy quality products at wholesale price