Search in sources :

Example 6 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class LiveData method loadFromXML.

public static LiveData loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
    LiveData liveData = new LiveData();
    Elements nodes = data.getElements();
    boolean doCommandLineUpgrade = true;
    ArrayList<LiveObject> oldFormat = new ArrayList<>();
    Element liveObjectSetsNode = null;
    while (nodes.hasMoreElements()) {
        Element node = nodes.next();
        String name = node.getName();
        switch(name) {
            case "commandLine":
                liveData.setCommandLine(node.getTextString());
                break;
            case "commandLineEnabled":
                liveData.setCommandLineEnabled(XMLUtilities.readBoolean(node));
                doCommandLineUpgrade = false;
                break;
            case "commandLineOverride":
                liveData.setCommandLineOverride(XMLUtilities.readBoolean(node));
                doCommandLineUpgrade = false;
                break;
            case "soundObject":
                SoundObject sObj = (SoundObject) ObjectUtilities.loadFromXML(node, objRefMap);
                LiveObject lObj = new LiveObject();
                lObj.setSObj(sObj);
                oldFormat.add(lObj);
                break;
            case "liveObject":
                oldFormat.add(LiveObject.loadFromXML(node, objRefMap));
                break;
            case "liveObjectBins":
                liveData.liveObjectBins = LiveObjectBins.loadFromXML(node, objRefMap);
                break;
            case "repeat":
                liveData.repeat = XMLUtilities.readInt(node);
                break;
            case "tempo":
                liveData.tempo = XMLUtilities.readInt(node);
                break;
            case "liveObjectSetList":
                liveObjectSetsNode = node;
                break;
            case "repeatEnabled":
                liveData.setRepeatEnabled(XMLUtilities.readBoolean(node));
                break;
            case "liveCodeText":
                liveData.setLiveCodeText(node.getTextString());
                break;
        }
    }
    if (oldFormat.size() > 0) {
        LiveObject[][] liveObjectBins = new LiveObject[1][oldFormat.size()];
        for (int i = 0; i < oldFormat.size(); i++) {
            liveObjectBins[0][i] = oldFormat.get(i);
        }
        liveData.liveObjectBins = new LiveObjectBins(liveObjectBins);
    }
    if (doCommandLineUpgrade) {
        liveData.setCommandLineEnabled(true);
        liveData.setCommandLineOverride(true);
    }
    if (liveObjectSetsNode != null) {
        liveData.liveObjectSets = LiveObjectSetList.loadFromXML(liveObjectSetsNode, liveData.liveObjectBins);
    }
    return liveData;
}
Also used : SoundObject(blue.soundObject.SoundObject) LiveObjectBins(blue.blueLive.LiveObjectBins) Element(electric.xml.Element) ArrayList(java.util.ArrayList) Elements(electric.xml.Elements) LiveObject(blue.blueLive.LiveObject)

Example 7 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class BlueLiveTopComponent method triggerButtonActionPerformed.

// GEN-LAST:event_noteTemplateTextMousePressed
private void triggerButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (data == null) {
        return;
    }
    LiveObjectSet liveObjects = data.getLiveData().getLiveObjectBins().getEnabledLiveObjectSet();
    if (liveObjects.size() > 0) {
        System.out.println("LiveObjectsSize: " + liveObjects.size());
        NoteList nl = new NoteList();
        try {
            for (LiveObject liveObj : liveObjects) {
                SoundObject sObj = liveObj.getSoundObject();
                if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
                    sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
            }
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
        int tempo = (Integer) tempoSpinner.getValue();
        ScoreUtilities.scaleScore(nl, 60.0f / tempo);
        String scoreText = nl.toString();
        if (scoreText != null && scoreText.length() > 0) {
            RealtimeRenderManager.getInstance().passToStdin(scoreText);
        }
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) LiveObjectSet(blue.blueLive.LiveObjectSet) BadLocationException(javax.swing.text.BadLocationException) LiveObject(blue.blueLive.LiveObject)

Example 8 with LiveObject

use of blue.blueLive.LiveObject in project blue by kunstmusik.

the class BlueLiveBinding method triggerLiveData.

protected void triggerLiveData() {
    LiveObjectSet liveObjects = data.getLiveObjectBins().getEnabledLiveObjectSet();
    if (liveObjects.size() > 0) {
        NoteList nl = new NoteList();
        try {
            for (LiveObject liveObj : liveObjects) {
                SoundObject sObj = liveObj.getSoundObject();
                if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
                    sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
            }
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
        ScoreUtilities.scaleScore(nl, 60.0f / data.getTempo());
        String scoreText = nl.toString();
        if (scoreText != null && scoreText.length() > 0) {
            // FIXME - this is certainly not good code but functions for now...
            BlueLiveToolBar.getInstance().sendEvents(scoreText);
        }
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) LiveObjectSet(blue.blueLive.LiveObjectSet) LiveObject(blue.blueLive.LiveObject)

Aggregations

LiveObject (blue.blueLive.LiveObject)8 SoundObject (blue.soundObject.SoundObject)3 LiveObjectBins (blue.blueLive.LiveObjectBins)2 LiveObjectSet (blue.blueLive.LiveObjectSet)2 NoteList (blue.soundObject.NoteList)2 Element (electric.xml.Element)2 TableModelEvent (javax.swing.event.TableModelEvent)2 GenericScore (blue.soundObject.GenericScore)1 Elements (electric.xml.Elements)1 ArrayList (java.util.ArrayList)1 BadLocationException (javax.swing.text.BadLocationException)1