Search in sources :

Example 46 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class AlgorithmCommonData method loadFromXML.

public static AlgorithmCommonData loadFromXML(Element data) {
    AlgorithmCommonData acd = new AlgorithmCommonData();
    acd.keyTranspose = XMLUtilities.readInt(data, "keyTranspose");
    acd.algorithm = XMLUtilities.readInt(data, "algorithm");
    acd.feedback = XMLUtilities.readInt(data, "feedback");
    Elements ops = data.getElements("operator");
    int counter = 0;
    while (ops.hasMoreElements()) {
        acd.operators[counter] = XMLUtilities.readBoolean(ops.next());
        counter++;
    }
    return acd;
}
Also used : Elements(electric.xml.Elements)

Example 47 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class ProjectProperties method loadFromXML.

public static ProjectProperties loadFromXML(Element data) {
    ProjectProperties retVal = new ProjectProperties();
    Elements nodes = data.getElements();
    String kr = null;
    String commandLine = null;
    String diskCommandLine = null;
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        String nodeVal = node.getTextString();
        switch(nodeName) {
            case "title":
                retVal.title = nodeVal;
                break;
            case "author":
                retVal.author = nodeVal;
                break;
            case "notes":
                retVal.notes = nodeVal;
                break;
            case "sampleRate":
                retVal.sampleRate = nodeVal;
                break;
            case "controlRate":
                kr = nodeVal;
                break;
            case "ksmps":
                retVal.ksmps = nodeVal;
                break;
            case "useZeroDbFS":
                retVal.useZeroDbFS = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "zeroDbFS":
                retVal.zeroDbFS = nodeVal;
                break;
            case "channels":
                retVal.channels = nodeVal;
                break;
            case "commandLine":
                commandLine = nodeVal;
                break;
            case "diskSampleRate":
                retVal.diskSampleRate = nodeVal;
                break;
            case "diskKsmps":
                retVal.diskKsmps = nodeVal;
                break;
            case "diskChannels":
                retVal.diskChannels = nodeVal;
                break;
            case "diskCommandLine":
                diskCommandLine = nodeVal;
                break;
            case "diskUseZeroDbFS":
                retVal.diskUseZeroDbFS = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskZeroDbFS":
                retVal.diskZeroDbFS = nodeVal;
                break;
            case "useAudioOut":
                retVal.useAudioOut = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "useAudioIn":
                retVal.useAudioIn = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "useMidiIn":
                retVal.useMidiIn = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "useMidiOut":
                retVal.useMidiOut = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "noteAmpsEnabled":
                retVal.noteAmpsEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "outOfRangeEnabled":
                retVal.outOfRangeEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "warningsEnabled":
                retVal.warningsEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "benchmarkEnabled":
                retVal.benchmarkEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "advancedSettings":
                retVal.advancedSettings = nodeVal;
                break;
            case "completeOverride":
                retVal.completeOverride = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "fileName":
                retVal.fileName = nodeVal;
                break;
            case "askOnRender":
                retVal.askOnRender = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskNoteAmpsEnabled":
                retVal.diskNoteAmpsEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskOutOfRangeEnabled":
                retVal.diskOutOfRangeEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskWarningsEnabled":
                retVal.diskWarningsEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskBenchmarkEnabled":
                retVal.diskBenchmarkEnabled = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskAdvancedSettings":
                retVal.diskAdvancedSettings = nodeVal;
                break;
            case "diskCompleteOverride":
                retVal.diskCompleteOverride = Boolean.valueOf(nodeVal).booleanValue();
                break;
            case "diskAlwaysRenderEntireProject":
                retVal.diskAlwaysRenderEntireProject = Boolean.valueOf(nodeVal).booleanValue();
                break;
        }
    }
    // Upgrade Migration for older values
    if (kr != null && kr.length() > 0 && retVal.ksmps != null && retVal.ksmps.length() == 0) {
        try {
            int ksmpsNum = Integer.parseInt(retVal.sampleRate) / Integer.parseInt(kr);
            retVal.ksmps = Integer.toString(ksmpsNum);
        } catch (NumberFormatException nfe) {
        }
    }
    if (commandLine != null) {
        retVal.advancedSettings = commandLine;
        retVal.completeOverride = true;
    }
    if (diskCommandLine != null) {
        retVal.diskAdvancedSettings = diskCommandLine;
        retVal.diskCompleteOverride = true;
    }
    ValuesUtility.checkNullString(retVal);
    return retVal;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 48 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class Arrangement method loadFromXML.

// OLD SAVING AND LOADING METHODS
/**
 * Used by old pre 0.95.0 code before instrument libraries removed from
 * project and user instrument library was implemented.
 *
 * This code is here to maintain compatibility with projects that still
 * contain InstrumentLibraries and is used when migrating to new format.
 *
 * @deprecated
 */
@Deprecated
public static Arrangement loadFromXML(Element data, InstrumentLibrary iLibrary) {
    Arrangement arr = new Arrangement();
    Elements items = data.getElements("instrumentAssignment");
    while (items.hasMoreElements()) {
        Element elem = items.next();
        InstrumentAssignment ia = InstrumentAssignment.loadFromXML(elem, iLibrary);
        arr.getArrangement().add(ia);
    }
    return arr;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 49 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class BlueData method loadFromXML.

public static BlueData loadFromXML(Element data) throws Exception {
    UpgradeManager.getInstance().performUpgrades(data);
    BlueData blueData = new BlueData();
    Map<String, Object> objRefMap = new HashMap<>();
    Elements nodes = data.getElements();
    Element instrumentLibraryNode = null;
    Element arrangementNode = null;
    Mixer m = null;
    Attribute versionAttribute = data.getAttribute("version");
    if (versionAttribute != null) {
        blueData.setVersion(versionAttribute.getValue());
    }
    BlueDataObjectManager bdoManager = Lookup.getDefault().lookup(BlueDataObjectManager.class);
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String nodeName = node.getName();
        switch(nodeName) {
            case "projectProperties":
                blueData.projectProperties = ProjectProperties.loadFromXML(node);
                break;
            case "instrumentLibrary":
                instrumentLibraryNode = node;
                break;
            case "arrangement":
                arrangementNode = node;
                break;
            case "mixer":
                m = Mixer.loadFromXML(node);
                break;
            case "tables":
                blueData.tableSet = Tables.loadFromXML(node);
                break;
            case "soundObjectLibrary":
                blueData.sObjLib = SoundObjectLibrary.loadFromXML(node, objRefMap);
                break;
            case "globalOrcSco":
                blueData.globalOrcSco = GlobalOrcSco.loadFromXML(node);
                break;
            case "udo":
                {
                    // blueData.setUserDefinedOpcodes(node.getTextString());
                    String udoText = node.getTextString();
                    if (udoText == null) {
                        udoText = "";
                    }
                    OpcodeList results = UDOUtilities.parseUDOText(udoText);
                    blueData.setOpcodeList(results);
                    break;
                }
            case "opcodeList":
                {
                    OpcodeList results = OpcodeList.loadFromXML(node);
                    blueData.setOpcodeList(results);
                    break;
                }
            case "liveData":
                blueData.liveData = LiveData.loadFromXML(node, objRefMap);
                break;
            case "score":
                blueData.score = Score.loadFromXML(node, objRefMap);
                break;
            case "scratchPadData":
                blueData.scratchData = ScratchPadData.loadFromXML(node);
                break;
            case "noteProcessorChainMap":
                blueData.noteProcessorChainMap = NoteProcessorChainMap.loadFromXML(node);
                break;
            case "renderStartTime":
                blueData.setRenderStartTime(Double.parseDouble(node.getTextString()));
                break;
            case "renderEndTime":
                blueData.setRenderEndTime(Double.parseDouble(node.getTextString()));
                break;
            case "markersList":
                blueData.setMarkersList(MarkersList.loadFromXML(node));
                break;
            case "loopRendering":
                blueData.setLoopRendering(node.getTextString().equalsIgnoreCase("true"));
                break;
            case "midiInputProcessor":
                blueData.midiInputProcessor = MidiInputProcessor.loadFromXML(node);
                break;
            case "pluginData":
                Elements pluginElems = node.getElements();
                while (pluginElems.hasMoreElements()) {
                    blueData.pluginData.add(bdoManager.loadFromXML(pluginElems.next()));
                }
                break;
        }
    }
    if (instrumentLibraryNode != null) {
        InstrumentLibrary instrumentLibrary = InstrumentLibrary.loadFromXML(instrumentLibraryNode);
        blueData.arrangement = Arrangement.loadFromXML(arrangementNode, instrumentLibrary);
    } else {
        blueData.arrangement = Arrangement.loadFromXML(arrangementNode);
    }
    if (m != null) {
        blueData.mixer = m;
    } else {
        blueData.mixer.setEnabled(false);
    }
    return blueData;
}
Also used : BlueDataObjectManager(blue.data.BlueDataObjectManager) Attribute(electric.xml.Attribute) OpcodeList(blue.udo.OpcodeList) Element(electric.xml.Element) Mixer(blue.mixer.Mixer) Elements(electric.xml.Elements)

Example 50 with Elements

use of electric.xml.Elements in project blue by kunstmusik.

the class LiveObject method loadFromXML.

public static LiveObject loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    LiveObject liveObj = new LiveObject();
    String val = data.getAttributeValue("uniqueId");
    if (val != null && val.length() > 0) {
        liveObj.uniqueId = val;
    }
    Elements nodes = data.getElements();
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String name = node.getName();
        switch(name) {
            case "keyTrigger":
                liveObj.setKeyTrigger(XMLUtilities.readInt(node));
                break;
            case "midiTrigger":
                liveObj.setMidiTrigger(XMLUtilities.readInt(node));
                break;
            case "soundObject":
                liveObj.setSObj((SoundObject) ObjectUtilities.loadFromXML(node, objRefMap));
                break;
            case "enabled":
                liveObj.setEnabled(XMLUtilities.readBoolean(node));
                break;
        }
    }
    return liveObj;
}
Also used : Element(electric.xml.Element) Elements(electric.xml.Elements)

Aggregations

Elements (electric.xml.Elements)131 Element (electric.xml.Element)120 Document (electric.xml.Document)12 BigDecimal (java.math.BigDecimal)10 Vector (java.util.Vector)10 File (java.io.File)4 SoundObject (blue.soundObject.SoundObject)3 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 ParseException (electric.xml.ParseException)3 ArrayList (java.util.ArrayList)3 ParameterList (blue.automation.ParameterList)2 Line (blue.components.lines.Line)2 Color (java.awt.Color)2 IOException (java.io.IOException)2 Font (javafx.scene.text.Font)2 LiveObject (blue.blueLive.LiveObject)1 LiveObjectBins (blue.blueLive.LiveObjectBins)1