use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.
the class Line method exportBPF.
/**
* Export line data values as BPF format
*
* @return
*/
public String exportBPF() {
if (points.size() == 0) {
return null;
}
StrBuilder builder = new StrBuilder();
for (Iterator iter = points.iterator(); iter.hasNext(); ) {
LinePoint point = (LinePoint) iter.next();
builder.append(point.getX()).append("\t").append(point.getY()).append("\n");
}
return builder.toString();
}
use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.
the class Mixer method getClearStatements.
public String getClearStatements(CompileData data, int nchnls) {
StrBuilder buffer = new StrBuilder();
List<Channel> allChannels = getAllSourceChannels();
for (Channel c : allChannels) {
for (int j = 0; j < nchnls; j++) {
buffer.append(getChannelVar(data.getChannelIdAssignments().get(c), j)).append(" = 0\n");
}
}
for (Channel c : subChannels) {
for (int j = 0; j < nchnls; j++) {
buffer.append(getSubChannelVar(c.getName(), j)).append(" = 0\n");
}
}
for (int j = 0; j < nchnls; j++) {
buffer.append(getSubChannelVar(MASTER_CHANNEL, j)).append(" = 0\n");
}
return buffer.toString();
}
use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.
the class MixerNode method getMixerCode.
/**
* Generates Csound Instrument for Mixer. Effects are added as UDO's to
* project. Code generations for Channels and SubChannels is optimized to
* not generate unnecessary code by following rules:
*
* <ol>
*
* <li> when processing Sends, checks down the graph to see if send signal
* will make it to the Master output or not, checking both down graph of
* output channels as well as sends for each channel. If not, does not
* generate output for Send. </li>
*
* <li> if channel does not have channel output and no valid prefader sends,
* do not generate anything </li>
* </ol>
*
* @param mixer
* @param udos
* @param manager
* @param node
* @param nchnls
* @return
*/
public static String getMixerCode(CompileData data, Mixer mixer, OpcodeList udos, EffectManager manager, MixerNode mixerNode, int nchnls) {
StrBuilder buffer = new StrBuilder();
List<MixerNode> nodes = new ArrayList<>();
flattenToList(mixerNode, nodes);
MixerNode.sortNodesList(nodes);
Set<String> inputSignalCache = new HashSet<>();
for (int i = 0; i < nodes.size(); i++) {
MixerNode tempNode = nodes.get(i);
// anything if not
if (mixer.isSubChannel(tempNode.channel) && !mixer.hasSubChannelDependency(tempNode.name) && !inputSignalCache.contains(tempNode.name)) {
continue;
}
// get signal string
String signalChannels = "";
for (int j = 0; j < nchnls; j++) {
if (j == 0) {
signalChannels = mixer.getVar(data, tempNode.channel, j);
} else {
signalChannels += ", " + mixer.getVar(data, tempNode.channel, j);
}
}
// apply pre-fader effects
EffectsChain preEffects = tempNode.channel.getPreEffects();
int lastIndex = Integer.MAX_VALUE;
if (!tempNode.generatesOutSignal) {
lastIndex = tempNode.lastPreFaderSendIndex;
if (lastIndex < 0) {
// skip as no sends and fader zeros signal
continue;
}
}
applyEffects(preEffects, udos, manager, signalChannels, buffer, lastIndex, inputSignalCache);
// stop processing here if fader will kill signal
if (tempNode.generatesOutSignal) {
// apply fader value
applyFader(data, mixer, tempNode, nchnls, buffer);
// apply post-fader effects
EffectsChain postEffects = tempNode.channel.getPostEffects();
lastIndex = Integer.MAX_VALUE;
if (!tempNode.outChannelValid) {
lastIndex = tempNode.lastPostFaderSendIndex;
if (lastIndex < 0) {
// skip as no sends and no out channel
continue;
// signal
}
}
applyEffects(postEffects, udos, manager, signalChannels, buffer, lastIndex, inputSignalCache);
// mix into out channel
if (tempNode.outChannelValid && i != nodes.size() - 1) {
String outChannelName = tempNode.channel.getOutChannel();
inputSignalCache.add(outChannelName);
for (int j = 0; j < nchnls; j++) {
String channelVar = mixer.getVar(data, tempNode.channel, j);
String outChannelVar = Mixer.getSubChannelVar(outChannelName, j);
buffer.append(outChannelVar).append("\t+=\t");
// buffer.append(outChannelVar).append(", ");
buffer.append(channelVar).append("\n");
}
}
}
}
return buffer.toString();
}
use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.
the class MixerNode method str.
private String str(int depth) {
StrBuilder retVal = new StrBuilder();
for (int i = 0; i < depth; i++) {
retVal.append(" ");
}
retVal.append(name).append("\n");
for (MixerNode m : children) {
retVal.append(m.str(depth + 2));
}
return retVal.toString();
}
use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.
the class BSBLineObject method getLineString.
private String getLineString(Line line) {
StrBuilder buffer = new StrBuilder();
double[] xVals = new double[line.size()];
double[] yVals = new double[line.size()];
for (int i = 0; i < line.size(); i++) {
LinePoint p = line.getLinePoint(i);
xVals[i] = p.getX() * getXMax();
yVals[i] = p.getY();
}
if (isRelativeXValues()) {
for (int i = xVals.length - 1; i > 0; i--) {
xVals[i] = xVals[i] - xVals[i - 1];
}
}
String spacer = getSeparatorType().getSeparatorString();
if (isLeadingZero()) {
buffer.append("0.0").append(spacer);
}
buffer.append(yVals[0]);
for (int i = 1; i < xVals.length; i++) {
buffer.append(spacer).append(NumberUtilities.formatDouble(xVals[i]));
buffer.append(spacer).append(NumberUtilities.formatDouble(yVals[i]));
}
return buffer.toString();
}
Aggregations