Search in sources :

Example 21 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class LayersPanel method populate.

private void populate() {
    this.checkSize();
    this.removeAll();
    if (pObj == null) {
        return;
    }
    for (SoundLayer sLayer : pObj) {
        SoundLayerPanel panel = new SoundLayerPanel(sLayer, npcMap);
        this.add(panel);
    }
    revalidate();
}
Also used : SoundLayer(blue.SoundLayer)

Example 22 with SoundLayer

use of blue.SoundLayer 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 23 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class PasteBSBAsSoundAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    double start = (double) p.x / timeState.getPixelSecond();
    if (timeState.isSnapEnabled()) {
        start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
    }
    Object obj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT);
    Sound sound = new Sound();
    sound.setStartTime(start);
    BlueSynthBuilder bsbCopy = ((BlueSynthBuilder) obj).deepCopy();
    // clear out any existing automations
    for (Parameter param : bsbCopy.getParameterList()) {
        param.setAutomationEnabled(false);
        param.getLine().clear();
        param.getLine().addLinePoint(new LinePoint(0.0, param.getValue(0.0)));
        param.getLine().addLinePoint(new LinePoint(1.0, param.getValue(0.0)));
    }
    sound.setBlueSynthBuilder(bsbCopy);
    Layer layer = scorePath.getGlobalLayerForY(p.y);
    if (!layer.accepts(sound)) {
        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;
    }
    SoundLayer sLayer = (SoundLayer) layer;
    sLayer.add(sound);
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    AddScoreObjectEdit undoEdit = new AddScoreObjectEdit(sLayer, sound);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(undoEdit);
}
Also used : BlueData(blue.BlueData) LinePoint(blue.components.lines.LinePoint) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Parameter(blue.automation.Parameter) ScoreObject(blue.score.ScoreObject) Sound(blue.soundObject.Sound) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer)

Example 24 with SoundLayer

use of blue.SoundLayer 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 25 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreTimeCanvas method paintComponent.

/**
 * ***********************************
 */
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int width = this.getWidth();
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, width, this.getHeight());
    if (getPolyObject() == null || timeState == null) {
        return;
    }
    int y = 0;
    g.setColor(Color.DARK_GRAY);
    g.drawLine(0, 0, width, 0);
    for (SoundLayer layer : getPolyObject()) {
        y += layer.getSoundLayerHeight();
        g.drawLine(0, y, width, y);
    }
    g.drawLine(0, getHeight() - 1, width, getHeight() - 1);
    if (timeState.isSnapEnabled()) {
        int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
        int x = 0;
        if (snapPixels <= 0) {
            return;
        }
        int height = getPolyObject().getTotalHeight();
        double snapValue = timeState.getSnapValue();
        int pixelSecond = timeState.getPixelSecond();
        double time;
        for (int i = 0; x < width; i++) {
            x = (int) ((i * snapValue) * pixelSecond);
            g.drawLine(x, 0, x, height);
        }
    }
}
Also used : SoundLayer(blue.SoundLayer) Point(java.awt.Point)

Aggregations

SoundLayer (blue.SoundLayer)27 SoundObject (blue.soundObject.SoundObject)10 PolyObject (blue.soundObject.PolyObject)9 Point (java.awt.Point)8 Layer (blue.score.layers.Layer)6 Instance (blue.soundObject.Instance)6 BlueData (blue.BlueData)5 ScoreObject (blue.score.ScoreObject)5 GenericScore (blue.soundObject.GenericScore)5 ArrayList (java.util.ArrayList)5 Score (blue.score.Score)3 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)3 Test (org.junit.Test)3 SoundObjectLibrary (blue.SoundObjectLibrary)2 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)2 Parameter (blue.automation.Parameter)1 LinePoint (blue.components.lines.LinePoint)1 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 External (blue.soundObject.External)1 NoteList (blue.soundObject.NoteList)1