Search in sources :

Example 46 with SoundObject

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

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

the class PasteAsPolyObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    List<Instance> instanceSoundObjects = new ArrayList<>();
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    double start = (double) p.x / timeState.getPixelSecond();
    if (timeState.isSnapEnabled()) {
        start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
    }
    int minLayer = Integer.MAX_VALUE;
    int maxLayer = Integer.MIN_VALUE;
    for (Integer layerIndex : layerIndexes) {
        if (layerIndex < minLayer) {
            minLayer = layerIndex;
        }
        if (layerIndex > maxLayer) {
            maxLayer = layerIndex;
        }
    }
    int numLayers = maxLayer - minLayer + 1;
    for (int i = 0; i < numLayers; i++) {
        pObj.newLayerAt(-1);
    }
    for (int i = 0; i < scoreObjects.size(); i++) {
        ScoreObject scoreObj = scoreObjects.get(i);
        int layerIndex = layerIndexes.get(i);
        SoundLayer layer = pObj.get(layerIndex - minLayer);
        SoundObject clone = (SoundObject) scoreObj.deepCopy();
        layer.add(clone);
        if (clone instanceof Instance) {
            instanceSoundObjects.add((Instance) clone);
        }
    }
    sObjLib.checkAndAddInstanceSoundObjects(instanceSoundObjects);
    pObj.normalizeSoundObjects();
    pObj.setStartTime(start);
    final ScoreObjectLayer layer = (ScoreObjectLayer) scorePath.getGlobalLayerForY(p.y);
    layer.add(pObj);
    AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, pObj);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(edit);
}
Also used : BlueData(blue.BlueData) Instance(blue.soundObject.Instance) ArrayList(java.util.ArrayList) ScoreObject(blue.score.ScoreObject) SoundObjectLibrary(blue.SoundObjectLibrary) Point(java.awt.Point) ScoreController(blue.ui.core.score.ScoreController) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer)

Example 48 with SoundObject

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

Example 49 with SoundObject

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

the class ScoreTimeCanvas method getToolTipText.

@Override
public String getToolTipText(MouseEvent e) {
    String tip = null;
    Object obj = this.getComponentAt(e.getPoint());
    if (obj instanceof SoundObjectView) {
        SoundObject sObj = ((SoundObjectView) obj).getSoundObject();
        double subjectiveDuration = sObj.getSubjectiveDuration();
        double startTime = sObj.getStartTime();
        Object[] args = { sObj.getName(), ObjectUtilities.getShortClassName(sObj), new Double(startTime), new Double(subjectiveDuration), new Double(startTime + subjectiveDuration) };
        tip = toolTipFormat.format(args);
    }
    return tip;
}
Also used : SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject) SoundObject(blue.soundObject.SoundObject)

Example 50 with SoundObject

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

the class ScoreTimeCanvas method setPolyObject.

public void setPolyObject(PolyObject pObj, TimeState timeState) {
    Component[] components = sObjPanel.getComponents();
    for (int i = 0; i < components.length; i++) {
        Component c = components[i];
        if (c instanceof SoundObjectView) {
            SoundObjectView sObjView = (SoundObjectView) c;
            sObjView.cleanup();
        }
    }
    sObjPanel.removeAll();
    this.soundObjectToViewMap.clear();
    marquee.setVisible(false);
    if (this.getPolyObject() != null) {
        this.timeState.removePropertyChangeListener(this);
        this.getPolyObject().removeLayerGroupListener(this);
        SoundLayer tempLayer;
        for (int i = 0; i < pObj.size(); i++) {
            tempLayer = pObj.get(i);
            tempLayer.removePropertyChangeListener(heightListener);
            tempLayer.removeSoundLayerListener(this);
        }
    }
    this.pObj = pObj;
    this.timeState = timeState;
    dropTargetListener.setTimeState(timeState);
    if (this.getPolyObject() != null) {
        timeState.addPropertyChangeListener(this);
        pObj.addLayerGroupListener(this);
    }
    this.automationPanel.setLayerGroup(pObj, timeState);
    // content.set(Collections.emptyList(), null);
    // TODO - REFACTOR THIS OUT TO POLY OBJECT CONTROLLER
    SoundLayer tempLayer;
    List<SoundObject> sObjects;
    int size = pObj.size();
    if (size != 0) {
        for (int i = 0; i < size; i++) {
            tempLayer = pObj.get(i);
            tempLayer.addPropertyChangeListener(heightListener);
            tempLayer.addSoundLayerListener(this);
            for (SoundObject tempSObj : tempLayer) {
                addSoundObjectView(i, tempSObj);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "ScoreTimeCanvas: setPObj found size == 0");
    }
    this.checkSize(true);
    this.revalidate();
    this.repaint();
}
Also used : SoundObject(blue.soundObject.SoundObject) SoundLayer(blue.SoundLayer) Component(java.awt.Component) Point(java.awt.Point)

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