use of electric.xml.Element in project blue by kunstmusik.
the class BSBHSliderBank method loadFromXML.
public static BSBObject loadFromXML(Element data) {
BSBHSliderBank sliderBank = new BSBHSliderBank();
double minVal = 0;
double maxVal = 1.0;
BigDecimal resolution = new BigDecimal("0.1");
initBasicFromXML(data, sliderBank);
Elements nodes = data.getElements();
sliderBank.getSliders().clear();
List<BSBHSlider> childSliders = new ArrayList<>();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "minimum":
minVal = Double.parseDouble(node.getTextString());
break;
case "maximum":
maxVal = Double.parseDouble(node.getTextString());
break;
case "resolution":
resolution = new BigDecimal(Double.parseDouble(node.getTextString())).setScale(5, RoundingMode.HALF_UP).stripTrailingZeros();
break;
case "bdresolution":
resolution = new BigDecimal(node.getTextString());
break;
case "sliderWidth":
sliderBank.setSliderWidth(Integer.parseInt(node.getTextString()));
break;
case "gap":
sliderBank.setGap(Integer.parseInt(node.getTextString()));
break;
case "randomizable":
sliderBank.setRandomizable(XMLUtilities.readBoolean(node));
break;
case "valueDisplayEnabled":
sliderBank.setValueDisplayEnabled(XMLUtilities.readBoolean(node));
break;
case "bsbObject":
BSBHSlider hSlider = (BSBHSlider) BSBHSlider.loadFromXML(node);
childSliders.add(hSlider);
break;
}
}
sliderBank.setValueProperty(new ClampedValue(minVal, maxVal, 0.0, resolution));
sliderBank.getSliders().addAll(childSliders);
return sliderBank;
}
use of electric.xml.Element in project blue by kunstmusik.
the class Operator method saveAsXML.
/**
* @return
*/
public Element saveAsXML() {
Element retVal = new Element("operator");
retVal.addElement(XMLUtilities.writeInt("mode", mode));
retVal.addElement(XMLUtilities.writeInt("sync", sync));
retVal.addElement(XMLUtilities.writeInt("freqCoarse", freqCoarse));
retVal.addElement(XMLUtilities.writeInt("freqFine", freqFine));
retVal.addElement(XMLUtilities.writeInt("detune", detune));
retVal.addElement(XMLUtilities.writeInt("breakpoint", breakpoint));
retVal.addElement(XMLUtilities.writeInt("curveLeft", curveLeft));
retVal.addElement(XMLUtilities.writeInt("curveRight", curveRight));
retVal.addElement(XMLUtilities.writeInt("depthLeft", depthLeft));
retVal.addElement(XMLUtilities.writeInt("depthRight", depthRight));
retVal.addElement(XMLUtilities.writeInt("keyboardRateScaling", keyboardRateScaling));
retVal.addElement(XMLUtilities.writeInt("outputLevel", outputLevel));
retVal.addElement(XMLUtilities.writeInt("velocitySensitivity", velocitySensitivity));
retVal.addElement(XMLUtilities.writeInt("modulationAmplitude", modulationAmplitude));
retVal.addElement(XMLUtilities.writeInt("modulationPitch", modulationPitch));
for (int i = 0; i < envelopePoints.length; i++) {
retVal.addElement(envelopePoints[i].saveAsXML());
}
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class Pattern method saveAsXML.
public Element saveAsXML() {
Element retVal = new Element("pattern");
retVal.addElement("patternName").setText(patternName);
retVal.addElement("patternScore").setText(patternScore);
retVal.addElement("muted").setText(Boolean.toString(muted));
retVal.addElement("solo").setText(Boolean.toString(solo));
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < values.length; i++) {
if (values[i]) {
buffer.append("1");
} else {
buffer.append("0");
}
}
retVal.addElement("values").setText(buffer.toString());
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class Scale method saveAsXML.
public Element saveAsXML() {
Element retVal = new Element("scale");
retVal.addElement("scaleName").setText(scaleName);
retVal.addElement("baseFrequency").setText(Double.toString(baseFrequency));
retVal.addElement("octave").setText(Double.toString(octave));
Element ratiosNode = retVal.addElement("ratios");
for (int i = 0; i < ratios.length; i++) {
Element node = new Element("ratio").setText(Double.toString(ratios[i]));
ratiosNode.addElement(node);
}
return retVal;
}
use of electric.xml.Element in project blue by kunstmusik.
the class Scale method loadFromXML.
/* SERIALIZATION */
public static Scale loadFromXML(Element data) {
Scale scale = new Scale();
Elements nodes = data.getElements();
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String nodeName = node.getName();
switch(nodeName) {
case "scaleName":
scale.scaleName = node.getTextString();
break;
case "baseFrequency":
scale.baseFrequency = Double.parseDouble(node.getTextString());
break;
case "octave":
scale.octave = Double.parseDouble(node.getTextString());
break;
case "ratios":
Elements ratioNodes = node.getElements();
scale.ratios = new double[ratioNodes.size()];
int i = 0;
while (ratioNodes.hasMoreElements()) {
Element ratioNode = ratioNodes.next();
scale.ratios[i] = Double.parseDouble(ratioNode.getTextString());
i++;
}
break;
}
}
return scale;
}
Aggregations