Search in sources :

Example 16 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreSection method setSoundObjectPerSection.

private static void setSoundObjectPerSection(BlueData data, ScoreSection section) {
    GenericScore genScore = createSizedGenericScore(section.scoreText, BlueSystem.getString("csd.importedScore"));
    genScore.setStartTime(section.sectionStartTime);
    PolyObject pObj = (PolyObject) data.getScore().get(0);
    SoundLayer sLayer = pObj.newLayerAt(-1);
    sLayer.add(genScore);
}
Also used : SoundLayer(blue.SoundLayer)

Example 17 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ReplaceWithBufferSoundObjectAction method getReplacementObject.

protected SoundObject getReplacementObject(ScoreController.ScoreObjectBuffer buffer, List<Instance> instances) {
    if (buffer.scoreObjects.size() == 1) {
        SoundObject sObj = (SoundObject) buffer.scoreObjects.get(0).deepCopy();
        if (sObj instanceof Instance) {
            instances.add((Instance) sObj);
        }
        return sObj;
    }
    PolyObject pObj = new PolyObject();
    int minLayer = Integer.MAX_VALUE;
    int maxLayer = Integer.MIN_VALUE;
    for (Integer layerIndex : buffer.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 < buffer.scoreObjects.size(); i++) {
        ScoreObject scoreObj = buffer.scoreObjects.get(i);
        int layerIndex = buffer.layerIndexes.get(i);
        SoundLayer layer = pObj.get(layerIndex - minLayer);
        SoundObject clone = (SoundObject) scoreObj.deepCopy();
        layer.add(clone);
        if (clone instanceof Instance) {
            instances.add((Instance) clone);
        }
    }
    return pObj;
}
Also used : SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) ScoreObject(blue.score.ScoreObject) PolyObject(blue.soundObject.PolyObject) Point(java.awt.Point)

Example 18 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class AddToSoundObjectLibraryAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    SoundObject sObj = (SoundObject) soundObjects.iterator().next().deepCopy();
    if (sObj instanceof Instance) {
        return;
    }
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    Instance i = new Instance(sObj);
    i.setStartTime(sObj.getStartTime());
    i.setSubjectiveDuration(sObj.getSubjectiveDuration());
    data.getSoundObjectLibrary().addSoundObject(sObj);
    SoundLayer layer = (SoundLayer) scorePath.getGlobalLayerForY(p.y);
    layer.remove(soundObjects.iterator().next());
    layer.add(i);
// BlueUndoManager.setUndoManager("score");
// BlueUndoManager.addEdit(new ReplaceScoreObjectEdit(
// sCanvas.getPolyObject(), oldSoundObject,
// newSoundObject, index));
}
Also used : BlueData(blue.BlueData) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer)

Example 19 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ConvertToObjectBuilderAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    SoundObject temp = soundObjects.iterator().next();
    int retVal = JOptionPane.showConfirmDialog(null, "This operation can not be undone.\nAre you sure?");
    if (retVal != JOptionPane.OK_OPTION) {
        return;
    }
    SoundLayer layer = (SoundLayer) scorePath.getGlobalLayerForY(p.y);
    ObjectBuilder objBuilder = new ObjectBuilder();
    if (temp instanceof PythonObject) {
        PythonObject tempPython = (PythonObject) temp;
        objBuilder.setName(tempPython.getName());
        objBuilder.setNoteProcessorChain(tempPython.getNoteProcessorChain());
        objBuilder.setTimeBehavior(tempPython.getTimeBehavior());
        objBuilder.setStartTime(tempPython.getStartTime());
        objBuilder.setSubjectiveDuration(tempPython.getSubjectiveDuration());
        objBuilder.setCode(tempPython.getText());
        objBuilder.setBackgroundColor(tempPython.getBackgroundColor());
    } else if (temp instanceof External) {
        External tempExt = (External) temp;
        objBuilder.setName(tempExt.getName());
        objBuilder.setNoteProcessorChain(tempExt.getNoteProcessorChain());
        objBuilder.setTimeBehavior(tempExt.getTimeBehavior());
        objBuilder.setStartTime(tempExt.getStartTime());
        objBuilder.setSubjectiveDuration(tempExt.getSubjectiveDuration());
        objBuilder.setCode(tempExt.getText());
        objBuilder.setCommandLine(tempExt.getCommandLine());
        objBuilder.setLanguageType(LanguageType.EXTERNAL);
        objBuilder.setBackgroundColor(tempExt.getBackgroundColor());
    } else {
        return;
    }
    layer.remove(temp);
    layer.add(objBuilder);
    ScoreController.getInstance().removeSelectedScoreObject(temp);
    ScoreController.getInstance().addSelectedScoreObject(objBuilder);
}
Also used : SoundObject(blue.soundObject.SoundObject) SoundLayer(blue.SoundLayer) External(blue.soundObject.External) ObjectBuilder(blue.soundObject.ObjectBuilder) Point(java.awt.Point) PythonObject(blue.soundObject.PythonObject)

Example 20 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ConvertToPolyObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    int retVal = JOptionPane.showConfirmDialog(null, "This operation can not be undone.\nAre you sure?");
    if (retVal != JOptionPane.OK_OPTION) {
        return;
    }
    List<Layer> allLayers = scorePath.getAllLayers();
    List<SoundObject> sObjList = new ArrayList<>();
    List<Integer> layerIndexes = new ArrayList<>();
    int layerMin = Integer.MAX_VALUE;
    int layerMax = Integer.MIN_VALUE;
    double start = Double.POSITIVE_INFINITY;
    for (SoundObject sObj : soundObjects) {
        sObjList.add(sObj);
        double sObjStart = sObj.getStartTime();
        if (sObj.getStartTime() < start) {
            start = sObj.getStartTime();
        }
        for (int i = 0; i < allLayers.size(); i++) {
            if (allLayers.get(i).contains(sObj)) {
                layerIndexes.add(i);
                if (i < layerMin) {
                    layerMin = i;
                }
                if (i > layerMax) {
                    layerMax = i;
                }
                break;
            }
        }
        if (sObjList.size() != layerIndexes.size()) {
            throw new RuntimeException("Error: Unable to find layer for SoundObject.");
        }
    }
    int numLayers = layerMax - layerMin + 1;
    for (int i = 0; i < numLayers; i++) {
        pObj.newLayerAt(-1);
    }
    for (int i = 0; i < sObjList.size(); i++) {
        SoundObject sObj = sObjList.get(i);
        int layerNum = layerIndexes.get(i);
        SoundLayer layer = (SoundLayer) allLayers.get(layerNum);
        layer.remove(sObj);
        // don't need to clone here...
        pObj.get(layerNum - layerMin).add(sObj);
    }
    pObj.normalizeSoundObjects();
    pObj.setStartTime(start);
    ((SoundLayer) scorePath.getGlobalLayerForY(p.y)).add(pObj);
    ScoreController.getInstance().setSelectedScoreObjects(Collections.singleton(pObj));
}
Also used : SoundObject(blue.soundObject.SoundObject) SoundLayer(blue.SoundLayer) ArrayList(java.util.ArrayList) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer) 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