use of blue.soundObject.Instance 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;
}
use of blue.soundObject.Instance 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));
}
use of blue.soundObject.Instance in project blue by kunstmusik.
the class ExportAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (scoreObjects.size() == 1 && soundObjects.size() == 1) {
File retVal = FileChooserManager.getDefault().showSaveDialog(EXPORT_DIALOG, WindowManager.getDefault().getMainWindow());
if (retVal != null) {
File f = retVal;
if (f.exists()) {
int overWrite = JOptionPane.showConfirmDialog(SwingUtilities.getRoot(WindowManager.getDefault().getMainWindow()), "Please confirm you would like to overwrite this file.");
if (overWrite != JOptionPane.OK_OPTION) {
return;
}
}
SoundObject sObj = soundObjects.iterator().next();
if ((sObj instanceof Instance) || ((sObj instanceof PolyObject) && containsInstance((PolyObject) sObj))) {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Export of Instance or " + "PolyObjects containing Instance " + "is not allowed.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
Element node = sObj.saveAsXML(null);
PrintWriter out;
try {
out = new PrintWriter(new FileWriter(f));
out.print(node.toString());
out.flush();
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
use of blue.soundObject.Instance in project blue by kunstmusik.
the class SoundObjectLibraryTopComponent method copyInstanceButtonActionPerformed.
// GEN-LAST:event_copyButtonActionPerformed
private void copyInstanceButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_copyInstanceButtonActionPerformed
int index = sObjLibTable.getSelectedRow();
if (index != -1) {
SoundObject originalSObj = sObjLib.getSoundObject(index);
Instance tempSObj = new Instance(originalSObj);
tempSObj.setStartTime(0.0f);
tempSObj.setSubjectiveDuration(tempSObj.getObjectiveDuration());
ScoreController.getInstance().setSelectedScoreObjects(Collections.singleton(tempSObj));
scoreObjectBuffer.clear();
scoreObjectBuffer.scoreObjects.add(tempSObj);
scoreObjectBuffer.layerIndexes.add(0);
}
}
use of blue.soundObject.Instance in project blue by kunstmusik.
the class PasteAsPolyObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
List<Instance> instanceSoundObjects = new ArrayList<>();
ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
double start = (double) p.x / timeState.getPixelSecond();
if (timeState.isSnapEnabled()) {
start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
}
int minLayer = Integer.MAX_VALUE;
int maxLayer = Integer.MIN_VALUE;
for (Integer layerIndex : 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 < scoreObjects.size(); i++) {
ScoreObject scoreObj = scoreObjects.get(i);
int layerIndex = layerIndexes.get(i);
SoundLayer layer = pObj.get(layerIndex - minLayer);
SoundObject clone = (SoundObject) scoreObj.deepCopy();
layer.add(clone);
if (clone instanceof Instance) {
instanceSoundObjects.add((Instance) clone);
}
}
sObjLib.checkAndAddInstanceSoundObjects(instanceSoundObjects);
pObj.normalizeSoundObjects();
pObj.setStartTime(start);
final ScoreObjectLayer layer = (ScoreObjectLayer) scorePath.getGlobalLayerForY(p.y);
layer.add(pObj);
AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, pObj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
}
Aggregations