StringBuilder base = new StringBuilder("[");
StringBuilder high = new StringBuilder("[");
StringBuilder power = new StringBuilder("[");
for (int i = 0; i < myFunctions.length; i++) {
FourierFunction func = (FourierFunction)myFunctions[i];
if (func.getFundamental() == 0.0f) {
throw new ScriptGenException("Cannot generate a Fourier Function that was built by specifiying all frequencies, amplitudes and phases");
}
base.append(func.getFundamental());
high.append(func.getCutoff());
power.append(func.getRms());
if ((i + 1) < myFunctions.length) {
base.append(",");
high.append(",");
power.append(",");
}
}
base.append("]");
high.append("]");
power.append("]");
py.append(String.format("%s.make_fourier_input('%s', dimensions=%d, base=%s, high=%s, power=%s)\n",
scriptData.get("netName"),
myName,
myFunctions.length,
base,
high,
power));
} else {
StringBuilder funcs = new StringBuilder("[");
for (int i = 0; i < myFunctions.length; i++) {
String functionName = String.format("Function%c%s%c%d",
(Character)scriptData.get("spaceDelim"),
myName.replaceAll("\\p{Blank}|\\p{Punct}", ((Character)scriptData.get("spaceDelim")).toString()),
(Character)scriptData.get("spaceDelim"),
i);
if (myFunctions[i] instanceof ConstantFunction) {
ConstantFunction func = (ConstantFunction)myFunctions[i];
py.append(String.format("%s = ConstantFunction(%d, %.3f)\n",
functionName,
func.getDimension(),
func.getValue()));
} else if (myFunctions[i] instanceof FourierFunction) {
FourierFunction func = (FourierFunction)myFunctions[i];
py.append(String.format("%s = FourierFunction(%f, %f, %f, %d)\n",
functionName,
func.getFundamental(),
func.getCutoff(),
func.getRms(),
func.getSeed()));
} else if (myFunctions[i] instanceof PostfixFunction) {
PostfixFunction func = (PostfixFunction)myFunctions[i];
py.append(String.format("%s = PostfixFunction('%s', %d)\n",
functionName,
func.getExpression(),
func.getDimension()));
}
funcs.append(functionName);
if ((i + 1) < myFunctions.length) {