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;
}
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);
}
}
}
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);
}
}
}
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());
}
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"));
}
}
Aggregations