Search in sources :

Example 11 with SoundObject

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

the class AddSoundObjectActionsPresenter method getPopupPresenter.

@Override
public JMenuItem getPopupPresenter() {
    if (menu == null) {
        menu = new JMenu("Add SoundObject");
        List<LazyPlugin<SoundObject>> plugins = LazyPluginFactory.loadPlugins("blue/score/soundObjects", SoundObject.class);
        for (LazyPlugin<SoundObject> plugin : plugins) {
            JMenuItem temp = new JMenuItem();
            temp.setText(BlueSystem.getString("soundLayerPopup.addNew") + " " + plugin.getDisplayName());
            temp.putClientProperty("plugin", plugin);
            temp.setActionCommand(plugin.getDisplayName());
            temp.addActionListener(this);
            menu.add(temp);
        }
    }
    return menu;
}
Also used : SoundObject(blue.soundObject.SoundObject) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin)

Example 12 with SoundObject

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

the class ImportSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
    List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
    if (!retVal.isEmpty()) {
        File f = retVal.get(0);
        Document doc;
        try {
            doc = new Document(f);
            Element root = doc.getRoot();
            if (root.getName().equals("soundObject")) {
                SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
                int start = p.x;
                Layer layer = scorePath.getGlobalLayerForY(p.y);
                if (timeState.isSnapEnabled()) {
                    int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
                    start = start - (start % snapPixels);
                }
                float startTime = (float) start / timeState.getPixelSecond();
                tempSobj.setStartTime(startTime);
                ((SoundLayer) layer).add(tempSobj);
                AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
                BlueUndoManager.setUndoManager("score");
                BlueUndoManager.addEdit(edit);
            } else {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Element(electric.xml.Element) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) Document(electric.xml.Document) File(java.io.File) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) Point(java.awt.Point)

Example 13 with SoundObject

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

the class PasteSoundObjectAction method checkAndAddInstanceSoundObjects.

private void checkAndAddInstanceSoundObjects(SoundObjectLibrary sObjLib, List<Instance> instanceSoundObjects) {
    Map<SoundObject, SoundObject> originalToCopyMap = new HashMap<>();
    for (Instance instance : instanceSoundObjects) {
        final SoundObject instanceSObj = instance.getSoundObject();
        if (!sObjLib.contains(instanceSObj)) {
            SoundObject copy;
            if (originalToCopyMap.containsKey(instanceSObj)) {
                copy = originalToCopyMap.get(instanceSObj);
            } else {
                copy = (SoundObject) instance.getSoundObject().deepCopy();
                sObjLib.addSoundObject(copy);
                originalToCopyMap.put(instanceSObj, copy);
            }
            instance.setSoundObject(copy);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) HashMap(java.util.HashMap) Instance(blue.soundObject.Instance)

Example 14 with SoundObject

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

the class SoundObjectLibraryUtilsTest method testRemoveLibrarySoundObject.

/**
 * Test of removeLibrarySoundObject method, of class SoundObjectLibraryUtils.
 */
@Test
public void testRemoveLibrarySoundObject() {
    BlueData data = new BlueData();
    Score score = data.getScore();
    PolyObject polyObj = new PolyObject(true);
    score.add(polyObj);
    SoundObjectLibrary library = data.getSoundObjectLibrary();
    SoundLayer layer = polyObj.newLayerAt(0);
    SoundObject sObj = new GenericScore();
    SoundObject sObj2 = new GenericScore();
    PolyObject pObjInner = new PolyObject(true);
    SoundLayer layerInner = pObjInner.newLayerAt(0);
    layerInner.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(new Instance(sObj));
    layer.add(sObj2);
    layer.add(pObjInner);
    library.add(sObj);
    assertEquals(5, layer.size());
    assertEquals(1, library.size());
    assertEquals(1, layerInner.size());
    SoundObjectLibraryUtils.removeLibrarySoundObject(data, sObj);
    assertEquals(2, layer.size());
    assertEquals(0, library.size());
    assertEquals(0, layerInner.size());
}
Also used : BlueData(blue.BlueData) Score(blue.score.Score) GenericScore(blue.soundObject.GenericScore) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) SoundLayer(blue.SoundLayer) SoundObjectLibrary(blue.SoundObjectLibrary) GenericScore(blue.soundObject.GenericScore) PolyObject(blue.soundObject.PolyObject) Test(org.junit.Test)

Example 15 with SoundObject

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

the class InstanceEditor method testSoundObject.

public final void testSoundObject() {
    if (this.instance == null) {
        return;
    }
    NoteList notes = null;
    try {
        SoundObject clone = instance.getSoundObject().deepCopy();
        notes = clone.generateForCSD(CompileData.createEmptyCompileData(), 0.0f, -1.0f);
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
        notes = null;
    }
    if (notes != null) {
        InfoDialog.showInformationDialog(SwingUtilities.getRoot(this), notes.toString(), BlueSystem.getString("soundObject.generatedScore"));
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject)

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