Search in sources :

Example 1 with Instance

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

the class SoundObjectLibrary method checkAndAddInstanceSoundObjects.

public void checkAndAddInstanceSoundObjects(List<Instance> instanceSoundObjects) {
    Map<SoundObject, SoundObject> originalToCopyMap = new HashMap<>();
    for (Instance instance : instanceSoundObjects) {
        final SoundObject instanceSObj = instance.getSoundObject();
        if (!this.contains(instanceSObj)) {
            SoundObject copy;
            if (originalToCopyMap.containsKey(instanceSObj)) {
                copy = originalToCopyMap.get(instanceSObj);
            } else {
                copy = instance.getSoundObject().deepCopy();
                this.addSoundObject(copy);
                originalToCopyMap.put(instanceSObj, copy);
            }
            instance.setSoundObject(copy);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) HashMap(java.util.HashMap) Instance(blue.soundObject.Instance)

Example 2 with Instance

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

the class PasteSoundObjectAction method checkAndAddInstanceSoundObjects.

private void checkAndAddInstanceSoundObjects(SoundObjectLibrary sObjLib, List<Instance> instanceSoundObjects) {
    Map<SoundObject, SoundObject> originalToCopyMap = new HashMap<>();
    for (Instance instance : instanceSoundObjects) {
        final SoundObject instanceSObj = instance.getSoundObject();
        if (!sObjLib.contains(instanceSObj)) {
            SoundObject copy;
            if (originalToCopyMap.containsKey(instanceSObj)) {
                copy = originalToCopyMap.get(instanceSObj);
            } else {
                copy = (SoundObject) instance.getSoundObject().deepCopy();
                sObjLib.addSoundObject(copy);
                originalToCopyMap.put(instanceSObj, copy);
            }
            instance.setSoundObject(copy);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) HashMap(java.util.HashMap) Instance(blue.soundObject.Instance)

Example 3 with Instance

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

the class ScoreObjectEditorTopComponent method editScoreObject.

public void editScoreObject(ScoreObject sObj) {
    if (currentSoundObject == sObj) {
        return;
    }
    currentSoundObject = sObj;
    cardLayout.show(editPanel, "none");
    if (sObj == null) {
        // JOptionPane.showMessageDialog(null, "yo");
        return;
    }
    ScoreObject sObjToEdit = sObj;
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    if (sObj instanceof Instance) {
        sObjToEdit = ((Instance) sObj).getSoundObject();
        this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY);
    } else if (data.getSoundObjectLibrary().contains(sObjToEdit)) {
        this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY);
    } else {
        this.setEditingLibraryObject(null);
    }
    ScoreObjectEditor editor = editors.get(sObjToEdit.getClass());
    if (editor == null) {
        for (Class c : sObjEditorMap.keySet()) {
            if (c.isAssignableFrom(sObjToEdit.getClass())) {
                LazyPlugin<ScoreObjectEditor> plugin = sObjEditorMap.get(c);
                editor = plugin.getInstance();
                editors.put(sObjToEdit.getClass(), editor);
                editPanel.add(editor, editor.getClass().getName());
                break;
            }
        }
    }
    if (editor == null) {
        DialogDisplayer.getDefault().notify(new NotifyDescriptor("Could not find editor for SoundObject of type: " + sObjToEdit.getClass().getCanonicalName(), "Error", NotifyDescriptor.DEFAULT_OPTION, NotifyDescriptor.ERROR_MESSAGE, null, null));
        return;
    }
    editor.editScoreObject(sObjToEdit);
    cardLayout.show(editPanel, editor.getClass().getName());
// Logger.getLogger(ScoreObjectEditorTopComponent.class.getName()).fine("SoundObject Selected: " + className);;
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) BlueData(blue.BlueData) Instance(blue.soundObject.Instance) ScoreObject(blue.score.ScoreObject) ScoreObjectEditor(blue.soundObject.editor.ScoreObjectEditor)

Example 4 with Instance

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

the class SoundObjectLibraryUtilsTest method testRemoveLibrarySoundObject.

/**
 * Test of removeLibrarySoundObject method, of class SoundObjectLibraryUtils.
 */
@Test
public void testRemoveLibrarySoundObject() {
    BlueData data = new BlueData();
    Score score = data.getScore();
    PolyObject polyObj = new PolyObject(true);
    score.add(polyObj);
    SoundObjectLibrary library = data.getSoundObjectLibrary();
    SoundLayer layer = polyObj.newLayerAt(0);
    SoundObject sObj = new GenericScore();
    SoundObject sObj2 = new GenericScore();
    PolyObject pObjInner = new PolyObject(true);
    SoundLayer layerInner = pObjInner.newLayerAt(0);
    layerInner.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(sObj2);
    layer.add(pObjInner);
    library.add(sObj);
    assertEquals(5, layer.size());
    assertEquals(1, library.size());
    assertEquals(1, layerInner.size());
    SoundObjectLibraryUtils.removeLibrarySoundObject(data, sObj);
    assertEquals(2, layer.size());
    assertEquals(0, library.size());
    assertEquals(0, layerInner.size());
}
Also used : BlueData(blue.BlueData) Score(blue.score.Score) GenericScore(blue.soundObject.GenericScore) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) SoundObjectLibrary(blue.SoundObjectLibrary) GenericScore(blue.soundObject.GenericScore) PolyObject(blue.soundObject.PolyObject) Test(org.junit.Test)

Example 5 with Instance

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

the class ReplaceWithBufferSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    List<Layer> layers = scorePath.getAllLayers();
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    List<Instance> instances = new ArrayList<>();
    ReplaceScoreObjectEdit top = null;
    for (SoundObject sObj : soundObjects) {
        SoundObject replacement = getReplacementObject(buffer, instances);
        replacement.setStartTime(sObj.getStartTime());
        replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
        ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
        layer.remove(sObj);
        layer.add(replacement);
        ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
        if (top == null) {
            top = edit;
        } else {
            top.addEdit(edit);
        }
    }
    // FIXME - this part is not undoable...
    sObjLib.checkAndAddInstanceSoundObjects(instances);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(top);
}
Also used : ScoreController(blue.ui.core.score.ScoreController) BlueData(blue.BlueData) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) ReplaceScoreObjectEdit(blue.ui.core.score.undo.ReplaceScoreObjectEdit) ArrayList(java.util.ArrayList) SoundObjectLibrary(blue.SoundObjectLibrary) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer)

Aggregations

Instance (blue.soundObject.Instance)13 SoundObject (blue.soundObject.SoundObject)11 SoundLayer (blue.SoundLayer)8 BlueData (blue.BlueData)6 PolyObject (blue.soundObject.PolyObject)6 SoundObjectLibrary (blue.SoundObjectLibrary)4 ScoreObject (blue.score.ScoreObject)4 ArrayList (java.util.ArrayList)4 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)3 ScoreController (blue.ui.core.score.ScoreController)3 Point (java.awt.Point)3 Layer (blue.score.layers.Layer)2 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)2 HashMap (java.util.HashMap)2 Score (blue.score.Score)1 GenericScore (blue.soundObject.GenericScore)1 ScoreObjectEditor (blue.soundObject.editor.ScoreObjectEditor)1 ReplaceScoreObjectEdit (blue.ui.core.score.undo.ReplaceScoreObjectEdit)1 Element (electric.xml.Element)1 File (java.io.File)1