use of blue.BlueData in project blue by kunstmusik.
the class RenderToDiskAndPlayAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
BlueProject project = BlueProjectManager.getInstance().getCurrentProject();
if (project != null) {
BlueData data = project.getData();
if (data != null) {
RenderToDiskUtility.getInstance().renderToDisk(data, f -> {
DiskRenderSettings settings = DiskRenderSettings.getInstance();
if (settings.externalPlayCommandEnabled) {
String command = settings.externalPlayCommand;
command = command.replaceAll("\\$outfile", f.getAbsolutePath());
try {
if (System.getProperty("os.name").contains("Windows")) {
Runtime.getRuntime().exec(command);
} else {
String[] cmdArray = ProcessConsole.splitCommandString(command);
Runtime.getRuntime().exec(cmdArray);
}
System.out.println(command);
} catch (Exception ex) {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not run command: " + command, "Error", JOptionPane.ERROR_MESSAGE);
System.err.println("[" + BlueSystem.getString("message.error") + "] - " + ex.getLocalizedMessage());
ex.printStackTrace();
}
} else {
SwingUtilities.invokeLater(() -> {
AudioFilePlayerTopComponent tc = (AudioFilePlayerTopComponent) WindowManager.getDefault().findTopComponent("AudioFilePlayerTopComponent");
tc.setAudioFile(f);
});
}
});
}
}
}
use of blue.BlueData in project blue by kunstmusik.
the class MarkersTopComponent method reinitialize.
protected void reinitialize() {
BlueProject project = BlueProjectManager.getInstance().getCurrentProject();
BlueData currentData = null;
if (project != null) {
currentData = project.getData();
}
this.data = currentData;
markersTable.setModel(currentData.getMarkersList());
markersTable.getColumnModel().getColumn(0).setPreferredWidth(100);
}
use of blue.BlueData 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);
}
use of blue.BlueData in project blue by kunstmusik.
the class PasteBSBAsSoundAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
double start = (double) p.x / timeState.getPixelSecond();
if (timeState.isSnapEnabled()) {
start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
}
Object obj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT);
Sound sound = new Sound();
sound.setStartTime(start);
BlueSynthBuilder bsbCopy = ((BlueSynthBuilder) obj).deepCopy();
// clear out any existing automations
for (Parameter param : bsbCopy.getParameterList()) {
param.setAutomationEnabled(false);
param.getLine().clear();
param.getLine().addLinePoint(new LinePoint(0.0, param.getValue(0.0)));
param.getLine().addLinePoint(new LinePoint(1.0, param.getValue(0.0)));
}
sound.setBlueSynthBuilder(bsbCopy);
Layer layer = scorePath.getGlobalLayerForY(p.y);
if (!layer.accepts(sound)) {
JOptionPane.showMessageDialog(null, "Unable to paste due to target layers not " + "accepting types of objects within the copy buffer (i.e. trying to " + "paste a SoundObject into an AudioLayer");
return;
}
SoundLayer sLayer = (SoundLayer) layer;
sLayer.add(sound);
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
AddScoreObjectEdit undoEdit = new AddScoreObjectEdit(sLayer, sound);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(undoEdit);
}
use of blue.BlueData in project blue by kunstmusik.
the class PasteSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
double start = (double) p.x / timeState.getPixelSecond();
if (timeState.isSnapEnabled()) {
start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
}
ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
List<Layer> allLayers = scorePath.getAllLayers();
int selectedLayerIndex = scorePath.getGlobalLayerIndexForY(p.y);
int minLayer = Integer.MAX_VALUE;
int maxLayer = Integer.MIN_VALUE;
double bufferStart = Double.POSITIVE_INFINITY;
for (int i = 0; i < buffer.scoreObjects.size(); i++) {
ScoreObject scoreObj = buffer.scoreObjects.get(i);
int layer = buffer.layerIndexes.get(i);
if (scoreObj.getStartTime() < bufferStart) {
bufferStart = scoreObj.getStartTime();
}
if (layer < minLayer) {
minLayer = layer;
}
if (layer > maxLayer) {
maxLayer = layer;
}
}
int layerTranslation = selectedLayerIndex - minLayer;
double startTranslation = start - bufferStart;
if ((maxLayer + layerTranslation) >= allLayers.size()) {
JOptionPane.showMessageDialog(null, "Not Enough Layers to Paste");
return;
}
for (int i = 0; i < buffer.scoreObjects.size(); i++) {
ScoreObject scoreObj = buffer.scoreObjects.get(i);
int index = buffer.layerIndexes.get(i);
Layer layer = allLayers.get(index + layerTranslation);
if (!layer.accepts(scoreObj)) {
JOptionPane.showMessageDialog(null, "Unable to paste due to target layers not " + "accepting types of objects within the copy buffer (i.e. trying to " + "paste a SoundObject into an AudioLayer");
return;
}
}
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
AddScoreObjectEdit undoEdit = null;
// FIXME - Need a generic way to handle shadow objects; perhaps need to
// deal with this in the model...
List<Instance> instanceSoundObjects = new ArrayList<>();
for (int i = 0; i < buffer.scoreObjects.size(); i++) {
ScoreObject sObj = buffer.scoreObjects.get(i).deepCopy();
int newLayerIndex = buffer.layerIndexes.get(i) + layerTranslation;
if (sObj instanceof Instance) {
instanceSoundObjects.add((Instance) sObj);
} else if (sObj instanceof PolyObject) {
PolyObject pObj = (PolyObject) sObj;
getInstancesFromPolyObject(instanceSoundObjects, pObj);
}
sObj.setStartTime(sObj.getStartTime() + startTranslation);
ScoreObjectLayer<ScoreObject> layer = (ScoreObjectLayer<ScoreObject>) allLayers.get(newLayerIndex);
layer.add(sObj);
AddScoreObjectEdit tempEdit = new AddScoreObjectEdit(layer, sObj);
if (undoEdit == null) {
undoEdit = tempEdit;
} else {
undoEdit.addSubEdit(tempEdit);
}
}
checkAndAddInstanceSoundObjects(sObjLib, instanceSoundObjects);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(undoEdit);
}
Aggregations