Search code examples
javaargumentssupercollider

How can I construct UGens with more than 5 arguments in JCollider


JCollider is a Java client for the SuperCollider sound synthesis server.

It has a stupid arbitrary limit of 5 arguments when constructing UGens. (see Documentation for UGen here) I'm referring to the ar method. They made made multiple copies of that method for variable numbers of arguments, but they stopped at 5 and I need 7. Those convenience functions look like this where they are defined.

public static GraphElem kr( String name, GraphElem in1, GraphElem in2, GraphElem in3, GraphElem in4, GraphElem in5 )
{
    return UGen.construct( name, kControlRate, -1, new GraphElem[] { in1, in2, in3, in4, in5 });
}

I tried just using the UGen.construct method myself, but it's apparently "not visible" from where I'm trying to use it (in a different package).

I then tried fixing this in the JCollider source by just extending the convenience methods to the equally stupid arbitrary limit of 7, but alas I couldn't compile it due to an ant script problem.

What is the correct way to use UGen.ar() with more than 5 arguments?


Solution

  • At the time I wrote that it was Java 1.4. So I decided that 5 was a good number :) (in fact it covers some reasonable percentage like 98% or so of the ugens). You can still use the inner part of what you pasted to work around it without touching the source, e.g. call UGen.construct( name, kControlRate, -1, new GraphElem[] { in1, in2, in3, in4, in5, in6, in7, ... }); Obviously nowadays you'd go for Java 5 style varargs.

    If you are willing to use another language, give ScalaCollider a try, it's a much smoother experience.