Search in sources :

Example 21 with PolyObject

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

the class RealtimeRenderManager method getPolyObjectPath.

private List<PolyObject> getPolyObjectPath(PolyObject pObj, SoundObject soundObject) {
    List<SoundObject> allSObj = pObj.getSoundObjects(true);
    List<PolyObject> retVal = null;
    if (allSObj.contains(soundObject)) {
        retVal = new ArrayList<>();
        retVal.add(pObj);
    } else {
        List<SoundObject> pObjs = allSObj.stream().filter(a -> a instanceof PolyObject).collect(Collectors.toList());
        for (SoundObject obj : pObjs) {
            PolyObject tempPObj = (PolyObject) obj;
            retVal = getPolyObjectPath(tempPObj, soundObject);
            if (retVal != null) {
                retVal.add(0, pObj);
                break;
            }
        }
    }
    return retVal;
}
Also used : RealtimeRenderService(blue.services.render.RealtimeRenderService) Score(blue.score.Score) PolyObject(blue.soundObject.PolyObject) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PlayModeListener(blue.event.PlayModeListener) WindowManager(org.openide.windows.WindowManager) RealtimeRenderSettings(blue.settings.RealtimeRenderSettings) Iterator(java.util.Iterator) SoundObject(blue.soundObject.SoundObject) Set(java.util.Set) Layer(blue.score.layers.Layer) Collectors(java.util.stream.Collectors) ExceptionDialog(blue.gui.ExceptionDialog) ScoreObjectLayerGroup(blue.score.layers.ScoreObjectLayerGroup) Mixer(blue.mixer.Mixer) LayerGroup(blue.score.layers.LayerGroup) BlueData(blue.BlueData) List(java.util.List) BlueSystem(blue.BlueSystem) ScoreObject(blue.score.ScoreObject) CsoundBinding(blue.services.render.CsoundBinding) RealtimeRenderServiceFactory(blue.services.render.RealtimeRenderServiceFactory) SoundObjectException(blue.soundObject.SoundObjectException) StatusDisplayer(org.openide.awt.StatusDisplayer) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Example 22 with PolyObject

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

the class ScoreObjectSelectionListener method editScoreObject.

protected void editScoreObject(Collection<? extends ScoreObject> selectedScoreObjects, ScoreObject scoreObj) {
    if (scoreObj instanceof PolyObject) {
        PolyObject pObj = (PolyObject) scoreObj;
        ScoreController.getInstance().editLayerGroup(pObj);
    } else {
        if (selectedScoreObjects.size() == 1) {
            ScoreObjectEditorTopComponent editor = (ScoreObjectEditorTopComponent) WindowManager.getDefault().findTopComponent("ScoreObjectEditorTopComponent");
            if (!editor.isOpened()) {
                editor.open();
            }
            editor.requestActive();
        }
    }
}
Also used : PolyObject(blue.soundObject.PolyObject) ScoreObjectEditorTopComponent(blue.ui.core.score.layers.soundObject.ScoreObjectEditorTopComponent)

Example 23 with PolyObject

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

the class AddSoundObjectActionsPresenter method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (pRef == null || sTimeCanvasRef == null) {
        return;
    }
    ScoreTimeCanvas sTimeCanvas = sTimeCanvasRef.get();
    Point p = pRef.get();
    int sLayerIndex = sTimeCanvas.getPolyObject().getLayerNumForY((int) p.getY());
    ScoreTopComponent stc = (ScoreTopComponent) WindowManager.getDefault().findTopComponent("ScoreTopComponent");
    LazyPlugin<SoundObject> plugin = (LazyPlugin<SoundObject>) ((JMenuItem) e.getSource()).getClientProperty("plugin");
    try {
        SoundObject sObj = (SoundObject) plugin.getInstance().getClass().newInstance();
        if (sObj instanceof PolyObject) {
            ((PolyObject) sObj).newLayerAt(0);
        }
        TimeState timeState = stc.getTimeState();
        double start = (double) p.getX() / timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
        }
        sObj.setStartTime(start);
        sTimeCanvas.getPolyObject().addSoundObject(sLayerIndex, sObj);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(new AddScoreObjectEdit(sTimeCanvas.getPolyObject().get(sLayerIndex), sObj));
    } catch (InstantiationException | IllegalAccessException ex) {
        Exceptions.printStackTrace(ex);
    }
}
Also used : Point(java.awt.Point) Point(java.awt.Point) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin) ScoreTopComponent(blue.ui.core.score.ScoreTopComponent) SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) TimeState(blue.score.TimeState) PolyObject(blue.soundObject.PolyObject)

Example 24 with PolyObject

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

the class PasteSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    double start = (double) p.x / timeState.getPixelSecond();
    if (timeState.isSnapEnabled()) {
        start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
    }
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    List<Layer> allLayers = scorePath.getAllLayers();
    int selectedLayerIndex = scorePath.getGlobalLayerIndexForY(p.y);
    int minLayer = Integer.MAX_VALUE;
    int maxLayer = Integer.MIN_VALUE;
    double bufferStart = Double.POSITIVE_INFINITY;
    for (int i = 0; i < buffer.scoreObjects.size(); i++) {
        ScoreObject scoreObj = buffer.scoreObjects.get(i);
        int layer = buffer.layerIndexes.get(i);
        if (scoreObj.getStartTime() < bufferStart) {
            bufferStart = scoreObj.getStartTime();
        }
        if (layer < minLayer) {
            minLayer = layer;
        }
        if (layer > maxLayer) {
            maxLayer = layer;
        }
    }
    int layerTranslation = selectedLayerIndex - minLayer;
    double startTranslation = start - bufferStart;
    if ((maxLayer + layerTranslation) >= allLayers.size()) {
        JOptionPane.showMessageDialog(null, "Not Enough Layers to Paste");
        return;
    }
    for (int i = 0; i < buffer.scoreObjects.size(); i++) {
        ScoreObject scoreObj = buffer.scoreObjects.get(i);
        int index = buffer.layerIndexes.get(i);
        Layer layer = allLayers.get(index + layerTranslation);
        if (!layer.accepts(scoreObj)) {
            JOptionPane.showMessageDialog(null, "Unable to paste due to target layers not " + "accepting types of objects within the copy buffer (i.e. trying to " + "paste a SoundObject into an AudioLayer");
            return;
        }
    }
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    AddScoreObjectEdit undoEdit = null;
    // FIXME - Need a generic way to handle shadow objects; perhaps need to
    // deal with this in the model...
    List<Instance> instanceSoundObjects = new ArrayList<>();
    for (int i = 0; i < buffer.scoreObjects.size(); i++) {
        ScoreObject sObj = buffer.scoreObjects.get(i).deepCopy();
        int newLayerIndex = buffer.layerIndexes.get(i) + layerTranslation;
        if (sObj instanceof Instance) {
            instanceSoundObjects.add((Instance) sObj);
        } else if (sObj instanceof PolyObject) {
            PolyObject pObj = (PolyObject) sObj;
            getInstancesFromPolyObject(instanceSoundObjects, pObj);
        }
        sObj.setStartTime(sObj.getStartTime() + startTranslation);
        ScoreObjectLayer<ScoreObject> layer = (ScoreObjectLayer<ScoreObject>) allLayers.get(newLayerIndex);
        layer.add(sObj);
        AddScoreObjectEdit tempEdit = new AddScoreObjectEdit(layer, sObj);
        if (undoEdit == null) {
            undoEdit = tempEdit;
        } else {
            undoEdit.addSubEdit(tempEdit);
        }
    }
    checkAndAddInstanceSoundObjects(sObjLib, instanceSoundObjects);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(undoEdit);
}
Also used : BlueData(blue.BlueData) Instance(blue.soundObject.Instance) ScoreObject(blue.score.ScoreObject) ArrayList(java.util.ArrayList) SoundObjectLibrary(blue.SoundObjectLibrary) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) Point(java.awt.Point) ScoreController(blue.ui.core.score.ScoreController) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) PolyObject(blue.soundObject.PolyObject)

Example 25 with PolyObject

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

the class PasteSoundObjectAction method getInstancesFromPolyObject.

private void getInstancesFromPolyObject(List<Instance> instanceSoundObjects, PolyObject pObj) {
    for (SoundLayer layer : pObj) {
        for (SoundObject sObj : layer) {
            if (sObj instanceof Instance) {
                Instance instance = (Instance) sObj;
                instanceSoundObjects.add(instance);
            } else if (sObj instanceof PolyObject) {
                getInstancesFromPolyObject(instanceSoundObjects, (PolyObject) sObj);
            }
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) PolyObject(blue.soundObject.PolyObject)

Aggregations

PolyObject (blue.soundObject.PolyObject)29 SoundLayer (blue.SoundLayer)10 SoundObject (blue.soundObject.SoundObject)10 BlueData (blue.BlueData)8 Score (blue.score.Score)8 Instance (blue.soundObject.Instance)6 ScoreObject (blue.score.ScoreObject)5 GenericScore (blue.soundObject.GenericScore)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 SoundObjectLibrary (blue.SoundObjectLibrary)3 Layer (blue.score.layers.Layer)3 LayerGroup (blue.score.layers.LayerGroup)3 AudioFile (blue.soundObject.AudioFile)3 File (java.io.File)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 AbstractLookup (org.openide.util.lookup.AbstractLookup)3 Mixer (blue.mixer.Mixer)2 TimeState (blue.score.TimeState)2