use of blue.soundObject.Instance in project blue by kunstmusik.
the class SoundObjectLibrary method checkAndAddInstanceSoundObjects.
public void checkAndAddInstanceSoundObjects(List<Instance> instanceSoundObjects) {
Map<SoundObject, SoundObject> originalToCopyMap = new HashMap<>();
for (Instance instance : instanceSoundObjects) {
final SoundObject instanceSObj = instance.getSoundObject();
if (!this.contains(instanceSObj)) {
SoundObject copy;
if (originalToCopyMap.containsKey(instanceSObj)) {
copy = originalToCopyMap.get(instanceSObj);
} else {
copy = instance.getSoundObject().deepCopy();
this.addSoundObject(copy);
originalToCopyMap.put(instanceSObj, copy);
}
instance.setSoundObject(copy);
}
}
}
use of blue.soundObject.Instance 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);
}
}
}
use of blue.soundObject.Instance in project blue by kunstmusik.
the class ScoreObjectEditorTopComponent method editScoreObject.
public void editScoreObject(ScoreObject sObj) {
if (currentSoundObject == sObj) {
return;
}
currentSoundObject = sObj;
cardLayout.show(editPanel, "none");
if (sObj == null) {
// JOptionPane.showMessageDialog(null, "yo");
return;
}
ScoreObject sObjToEdit = sObj;
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
if (sObj instanceof Instance) {
sObjToEdit = ((Instance) sObj).getSoundObject();
this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY);
} else if (data.getSoundObjectLibrary().contains(sObjToEdit)) {
this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY);
} else {
this.setEditingLibraryObject(null);
}
ScoreObjectEditor editor = editors.get(sObjToEdit.getClass());
if (editor == null) {
for (Class c : sObjEditorMap.keySet()) {
if (c.isAssignableFrom(sObjToEdit.getClass())) {
LazyPlugin<ScoreObjectEditor> plugin = sObjEditorMap.get(c);
editor = plugin.getInstance();
editors.put(sObjToEdit.getClass(), editor);
editPanel.add(editor, editor.getClass().getName());
break;
}
}
}
if (editor == null) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor("Could not find editor for SoundObject of type: " + sObjToEdit.getClass().getCanonicalName(), "Error", NotifyDescriptor.DEFAULT_OPTION, NotifyDescriptor.ERROR_MESSAGE, null, null));
return;
}
editor.editScoreObject(sObjToEdit);
cardLayout.show(editPanel, editor.getClass().getName());
// Logger.getLogger(ScoreObjectEditorTopComponent.class.getName()).fine("SoundObject Selected: " + className);;
}
use of blue.soundObject.Instance 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());
}
use of blue.soundObject.Instance in project blue by kunstmusik.
the class ReplaceWithBufferSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
List<Layer> layers = scorePath.getAllLayers();
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
List<Instance> instances = new ArrayList<>();
ReplaceScoreObjectEdit top = null;
for (SoundObject sObj : soundObjects) {
SoundObject replacement = getReplacementObject(buffer, instances);
replacement.setStartTime(sObj.getStartTime());
replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
layer.remove(sObj);
layer.add(replacement);
ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
if (top == null) {
top = edit;
} else {
top.addEdit(edit);
}
}
// FIXME - this part is not undoable...
sObjLib.checkAndAddInstanceSoundObjects(instances);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(top);
}
Aggregations