Search in sources :

Example 26 with SoundObject

use of blue.soundObject.SoundObject 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 27 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class SoundObjectLibrary method saveAsXML.

public Element saveAsXML(Map<Object, String> objRefMap) {
    Element retVal = new Element("soundObjectLibrary");
    for (SoundObject sObj : this) {
        String objRefId = Integer.toString(new VMID().hashCode());
        objRefMap.put(sObj, objRefId);
        Element elem = sObj.saveAsXML(objRefMap);
        elem.setAttribute("objRefId", objRefId);
        retVal.addElement(elem);
    }
    return retVal;
}
Also used : SoundObject(blue.soundObject.SoundObject) Element(electric.xml.Element) VMID(java.rmi.dgc.VMID)

Example 28 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class PatternLayerPanel method otherMenuButtonActionPerformed.

// GEN-LAST:event_soloToggleButtonActionPerformed
@SuppressWarnings("unchecked")
private void otherMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_otherMenuButtonActionPerformed
    Class<? extends SoundObject> current = patternLayer.getSoundObject().getClass();
    for (Component c : changeSObjMenu.getMenuComponents()) {
        JMenuItem menuItem = (JMenuItem) c;
        Class<? extends SoundObject> clazz = (Class<? extends SoundObject>) menuItem.getClientProperty("sObjClass");
        menuItem.setEnabled(!current.equals(clazz));
    }
    ScoreController controller = ScoreController.getInstance();
    Collection<? extends ScoreObject> selected = controller.getSelectedScoreObjects();
    setSObjFromBufferMenuItem.setEnabled(selected.size() == 1 && selected.iterator().next() instanceof SoundObject);
    jPopupMenu1.show(otherMenuButton, 0, otherMenuButton.getHeight());
}
Also used : ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject) ScoreObjectEditorTopComponent(blue.ui.core.score.layers.soundObject.ScoreObjectEditorTopComponent) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem)

Example 29 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class OpenProjectAction method reconcileAudioFiles.

private static void reconcileAudioFiles(PolyObject pObj, Map<String, String> map) {
    for (SoundObject sObj : pObj.getSoundObjects(true)) {
        if (sObj instanceof AudioFile) {
            AudioFile af = (AudioFile) sObj;
            String soundFileName = af.getSoundFileName();
            if (map.containsKey(soundFileName)) {
                af.setSoundFileName(map.get(soundFileName));
            }
        } else if (sObj instanceof PolyObject) {
            reconcileAudioFiles((PolyObject) sObj, map);
        }
    }
}
Also used : AudioFile(blue.soundObject.AudioFile) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Example 30 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class BlueLiveTopComponent method triggerLiveObject.

protected void triggerLiveObject(LiveObject liveObject) {
    NoteList nl = null;
    try {
        SoundObject sObj = liveObject.getSoundObject();
        if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
            sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
        }
        nl = sObj.generateForCSD(compileData, 0.0f, -1.0f);
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
    }
    if (nl == null) {
        return;
    }
    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) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

SoundObject (blue.soundObject.SoundObject)53 SoundLayer (blue.SoundLayer)12 Instance (blue.soundObject.Instance)11 PolyObject (blue.soundObject.PolyObject)11 ScoreObject (blue.score.ScoreObject)8 ArrayList (java.util.ArrayList)8 Element (electric.xml.Element)7 Point (java.awt.Point)7 IOException (java.io.IOException)6 BlueData (blue.BlueData)5 Layer (blue.score.layers.Layer)5 NoteList (blue.soundObject.NoteList)5 ScoreController (blue.ui.core.score.ScoreController)5 HashMap (java.util.HashMap)5 SoundObjectLibrary (blue.SoundObjectLibrary)4 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)4 Document (electric.xml.Document)4 ParseException (electric.xml.ParseException)4 File (java.io.File)4 LiveObject (blue.blueLive.LiveObject)3