use of blue.SoundLayer in project blue by kunstmusik.
the class ScoreSection method setSoundObjectPerSection.
private static void setSoundObjectPerSection(BlueData data, ScoreSection section) {
GenericScore genScore = createSizedGenericScore(section.scoreText, BlueSystem.getString("csd.importedScore"));
genScore.setStartTime(section.sectionStartTime);
PolyObject pObj = (PolyObject) data.getScore().get(0);
SoundLayer sLayer = pObj.newLayerAt(-1);
sLayer.add(genScore);
}
use of blue.SoundLayer 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.SoundLayer 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.SoundLayer in project blue by kunstmusik.
the class ConvertToObjectBuilderAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
SoundObject temp = soundObjects.iterator().next();
int retVal = JOptionPane.showConfirmDialog(null, "This operation can not be undone.\nAre you sure?");
if (retVal != JOptionPane.OK_OPTION) {
return;
}
SoundLayer layer = (SoundLayer) scorePath.getGlobalLayerForY(p.y);
ObjectBuilder objBuilder = new ObjectBuilder();
if (temp instanceof PythonObject) {
PythonObject tempPython = (PythonObject) temp;
objBuilder.setName(tempPython.getName());
objBuilder.setNoteProcessorChain(tempPython.getNoteProcessorChain());
objBuilder.setTimeBehavior(tempPython.getTimeBehavior());
objBuilder.setStartTime(tempPython.getStartTime());
objBuilder.setSubjectiveDuration(tempPython.getSubjectiveDuration());
objBuilder.setCode(tempPython.getText());
objBuilder.setBackgroundColor(tempPython.getBackgroundColor());
} else if (temp instanceof External) {
External tempExt = (External) temp;
objBuilder.setName(tempExt.getName());
objBuilder.setNoteProcessorChain(tempExt.getNoteProcessorChain());
objBuilder.setTimeBehavior(tempExt.getTimeBehavior());
objBuilder.setStartTime(tempExt.getStartTime());
objBuilder.setSubjectiveDuration(tempExt.getSubjectiveDuration());
objBuilder.setCode(tempExt.getText());
objBuilder.setCommandLine(tempExt.getCommandLine());
objBuilder.setLanguageType(LanguageType.EXTERNAL);
objBuilder.setBackgroundColor(tempExt.getBackgroundColor());
} else {
return;
}
layer.remove(temp);
layer.add(objBuilder);
ScoreController.getInstance().removeSelectedScoreObject(temp);
ScoreController.getInstance().addSelectedScoreObject(objBuilder);
}
use of blue.SoundLayer in project blue by kunstmusik.
the class ConvertToPolyObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
int retVal = JOptionPane.showConfirmDialog(null, "This operation can not be undone.\nAre you sure?");
if (retVal != JOptionPane.OK_OPTION) {
return;
}
List<Layer> allLayers = scorePath.getAllLayers();
List<SoundObject> sObjList = new ArrayList<>();
List<Integer> layerIndexes = new ArrayList<>();
int layerMin = Integer.MAX_VALUE;
int layerMax = Integer.MIN_VALUE;
double start = Double.POSITIVE_INFINITY;
for (SoundObject sObj : soundObjects) {
sObjList.add(sObj);
double sObjStart = sObj.getStartTime();
if (sObj.getStartTime() < start) {
start = sObj.getStartTime();
}
for (int i = 0; i < allLayers.size(); i++) {
if (allLayers.get(i).contains(sObj)) {
layerIndexes.add(i);
if (i < layerMin) {
layerMin = i;
}
if (i > layerMax) {
layerMax = i;
}
break;
}
}
if (sObjList.size() != layerIndexes.size()) {
throw new RuntimeException("Error: Unable to find layer for SoundObject.");
}
}
int numLayers = layerMax - layerMin + 1;
for (int i = 0; i < numLayers; i++) {
pObj.newLayerAt(-1);
}
for (int i = 0; i < sObjList.size(); i++) {
SoundObject sObj = sObjList.get(i);
int layerNum = layerIndexes.get(i);
SoundLayer layer = (SoundLayer) allLayers.get(layerNum);
layer.remove(sObj);
// don't need to clone here...
pObj.get(layerNum - layerMin).add(sObj);
}
pObj.normalizeSoundObjects();
pObj.setStartTime(start);
((SoundLayer) scorePath.getGlobalLayerForY(p.y)).add(pObj);
ScoreController.getInstance().setSelectedScoreObjects(Collections.singleton(pObj));
}
Aggregations