Search in sources :

Example 31 with SoundObject

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

the class BlueLiveTopComponent method triggerButtonActionPerformed.

// GEN-LAST:event_noteTemplateTextMousePressed
private void triggerButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (data == null) {
        return;
    }
    LiveObjectSet liveObjects = data.getLiveData().getLiveObjectBins().getEnabledLiveObjectSet();
    if (liveObjects.size() > 0) {
        System.out.println("LiveObjectsSize: " + liveObjects.size());
        NoteList nl = new NoteList();
        try {
            for (LiveObject liveObj : liveObjects) {
                SoundObject sObj = liveObj.getSoundObject();
                if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
                    sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
            }
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
        int tempo = (Integer) tempoSpinner.getValue();
        ScoreUtilities.scaleScore(nl, 60.0f / tempo);
        String scoreText = nl.toString();
        if (scoreText != null && scoreText.length() > 0) {
            RealtimeRenderManager.getInstance().passToStdin(scoreText);
        }
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) LiveObjectSet(blue.blueLive.LiveObjectSet) BadLocationException(javax.swing.text.BadLocationException) LiveObject(blue.blueLive.LiveObject)

Example 32 with SoundObject

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

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

the class SetSubjectiveToObjectiveTimeAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (soundObjects.size() > 0 && scoreObjects.size() == soundObjects.size()) {
        ResizeScoreObjectEdit top = null;
        for (SoundObject soundObject : soundObjects) {
            if (soundObject.getObjectiveDuration() <= 0) {
                JOptionPane.showMessageDialog(null, BlueSystem.getString("soundObjectPopup.setTime.error.text"), BlueSystem.getString("soundObjectPopup.setTime.error.title"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            double oldTime = soundObject.getSubjectiveDuration();
            double newTime = soundObject.getObjectiveDuration();
            if (oldTime != newTime) {
                soundObject.setSubjectiveDuration(newTime);
                ResizeScoreObjectEdit edit = new ResizeScoreObjectEdit(soundObject, oldTime, newTime);
                if (top == null) {
                    top = edit;
                } else {
                    top.addEdit(edit);
                }
            }
        }
        if (top != null) {
            BlueUndoManager.setUndoManager("score");
            BlueUndoManager.addEdit(top);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) ResizeScoreObjectEdit(blue.ui.core.score.undo.ResizeScoreObjectEdit)

Example 34 with SoundObject

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

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

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