Search in sources :

Example 1 with Score

use of blue.score.Score in project blue by kunstmusik.

the class BlueProjectPropertyChangeListener method detachListeners.

protected void detachListeners(BlueProject project) {
    if (project == null) {
        return;
    }
    Score score = project.getData().getScore();
    for (LayerGroup<? extends Layer> lg : score) {
        if (lg instanceof AudioLayerGroup) {
            lg.removeLayerGroupListener(layerGroupListener);
        }
    }
    score.removeListener(scoreListener);
}
Also used : Score(blue.score.Score) AudioLayerGroup(blue.score.layers.audio.core.AudioLayerGroup)

Example 2 with Score

use of blue.score.Score in project blue by kunstmusik.

the class BlueProjectManager method setCurrentProject.

public void setCurrentProject(BlueProject project) {
    BlueProject previousProject = currentProject;
    currentProject = project;
    if (!projects.contains(project)) {
        addProject(project);
    }
    if (currentProject != null) {
        BlueUndoManager.setUndoGroup(project.getUndoManager());
        File f = project.getDataFile();
        BlueSystem.setCurrentBlueData(project.getData());
        if (f != null) {
            BlueSystem.setCurrentProjectDirectory(f.getParentFile());
        } else {
            BlueSystem.setCurrentProjectDirectory(null);
        }
        final Score score = project.getData().getScore();
        Collection<? extends ProjectPlugin> plugins = Lookups.forPath("blue/project/plugins").lookupAll(ProjectPlugin.class);
        for (ProjectPlugin plugin : plugins) {
            plugin.preRender(project.getData());
        }
        new Thread(() -> {
            try {
                score.processOnLoad();
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }).start();
    }
    fireUpdatedCurrentProject(previousProject, currentProject);
}
Also used : Score(blue.score.Score) File(java.io.File) IOException(java.io.IOException) ProjectPlugin(blue.project.ProjectPlugin)

Example 3 with Score

use of blue.score.Score in project blue by kunstmusik.

the class OpenProjectAction method checkDependencies.

private static void checkDependencies(BlueData tempData) {
    Score score = tempData.getScore();
    ArrayList<String> filesList = new ArrayList<>();
    for (LayerGroup<?> layerGroup : score) {
        if (!(layerGroup instanceof PolyObject)) {
            continue;
        }
        PolyObject pObj = (PolyObject) layerGroup;
        checkAudioFiles(pObj, filesList);
    }
    if (filesList.size() > 0) {
        if (dependencyDialog == null) {
            dependencyDialog = new AudioFileDependencyDialog();
        }
        dependencyDialog.setFilesList(filesList);
        if (dependencyDialog.ask()) {
            Map<String, String> map = dependencyDialog.getFilesMap();
            if (map == null || map.size() == 0) {
                return;
            }
            for (Entry<String, String> entry : map.entrySet()) {
                String key = entry.getKey();
                String val = entry.getValue();
                val = BlueSystem.getRelativePath(val);
                entry.setValue(val);
            }
            System.out.println(map);
            for (LayerGroup<?> layerGroup : score) {
                if (!(layerGroup instanceof PolyObject)) {
                    continue;
                }
                PolyObject pObj = (PolyObject) layerGroup;
                reconcileAudioFiles(pObj, map);
            }
        }
    }
}
Also used : Score(blue.score.Score) ArrayList(java.util.ArrayList) PolyObject(blue.soundObject.PolyObject)

Example 4 with Score

use of blue.score.Score in project blue by kunstmusik.

the class ScoreController method deleteScoreObjects.

public void deleteScoreObjects() {
    if (lookup == null || content == null) {
        return;
    }
    Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
    Score score = lookup.lookup(Score.class);
    if (score == null) {
        throw new RuntimeException("Score object not set in ScoreController: internal error");
    }
    if (scoreObjects.isEmpty()) {
        return;
    }
    List<Layer> layers = getScorePath().getAllLayers();
    RemoveScoreObjectEdit top = null;
    for (ScoreObject scoreObj : scoreObjects) {
        RemoveScoreObjectEdit edit = null;
        for (Layer layer : layers) {
            if (layer.remove(scoreObj)) {
                edit = new RemoveScoreObjectEdit((ScoreObjectLayer) layer, scoreObj);
                break;
            }
        }
        if (edit == null) {
            throw new RuntimeException("Error: Unable to find Layer to remove ScoreObject: Internal Error");
        }
        if (top == null) {
            top = edit;
        } else {
            top.appendNextEdit(edit);
        }
        content.remove(scoreObj);
    }
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(top);
}
Also used : Score(blue.score.Score) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) RemoveScoreObjectEdit(blue.ui.core.score.undo.RemoveScoreObjectEdit) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 5 with Score

use of blue.score.Score 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)

Aggregations

Score (blue.score.Score)13 PolyObject (blue.soundObject.PolyObject)7 GenericScore (blue.soundObject.GenericScore)4 SoundLayer (blue.SoundLayer)3 Test (org.junit.Test)3 AbstractLookup (org.openide.util.lookup.AbstractLookup)3 BlueData (blue.BlueData)2 SoundObjectLibrary (blue.SoundObjectLibrary)2 ScoreObject (blue.score.ScoreObject)2 Layer (blue.score.layers.Layer)2 LayerGroup (blue.score.layers.LayerGroup)2 AudioLayerGroup (blue.score.layers.audio.core.AudioLayerGroup)2 SoundObject (blue.soundObject.SoundObject)2 Lookup (org.openide.util.Lookup)2 Channel (blue.mixer.Channel)1 ChannelList (blue.mixer.ChannelList)1 Mixer (blue.mixer.Mixer)1 ProjectPlugin (blue.project.ProjectPlugin)1 BlueProject (blue.projects.BlueProject)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1