Search in sources :

Example 46 with Element

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;
}
Also used : Element(electric.xml.Element) ArrayList(java.util.ArrayList) Elements(electric.xml.Elements) BigDecimal(java.math.BigDecimal)

Example 47 with Element

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;
}
Also used : Element(electric.xml.Element)

Example 48 with Element

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;
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Element(electric.xml.Element)

Example 49 with Element

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;
}
Also used : Element(electric.xml.Element)

Example 50 with Element

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;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Aggregations

Element (electric.xml.Element)310 Elements (electric.xml.Elements)120 Document (electric.xml.Document)22 Vector (java.util.Vector)14 Iterator (java.util.Iterator)12 File (java.io.File)10 BigDecimal (java.math.BigDecimal)10 IOException (java.io.IOException)8 SoundObject (blue.soundObject.SoundObject)7 ParseException (electric.xml.ParseException)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 EffectOption (blue.tools.blueShare.effects.EffectOption)3 InstrumentOption (blue.tools.blueShare.instruments.InstrumentOption)3 SoundObjectOption (blue.tools.blueShare.soundObjects.SoundObjectOption)3 OpcodeList (blue.udo.OpcodeList)3 Test (org.junit.Test)3 ParameterList (blue.automation.ParameterList)2 LiveObject (blue.blueLive.LiveObject)2 LiveObjectBins (blue.blueLive.LiveObjectBins)2 Line (blue.components.lines.Line)2