use of blue.SoundLayer in project blue by kunstmusik.
the class LayersPanel method populate.
private void populate() {
this.checkSize();
this.removeAll();
if (pObj == null) {
return;
}
for (SoundLayer sLayer : pObj) {
SoundLayerPanel panel = new SoundLayerPanel(sLayer, npcMap);
this.add(panel);
}
revalidate();
}
use of blue.SoundLayer 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.SoundLayer 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.SoundLayer in project blue by kunstmusik.
the class PasteSoundObjectAction method getInstancesFromPolyObject.
private void getInstancesFromPolyObject(List<Instance> instanceSoundObjects, PolyObject pObj) {
for (SoundLayer layer : pObj) {
for (SoundObject sObj : layer) {
if (sObj instanceof Instance) {
Instance instance = (Instance) sObj;
instanceSoundObjects.add(instance);
} else if (sObj instanceof PolyObject) {
getInstancesFromPolyObject(instanceSoundObjects, (PolyObject) sObj);
}
}
}
}
use of blue.SoundLayer in project blue by kunstmusik.
the class ScoreTimeCanvas method paintComponent.
/**
* ***********************************
*/
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
int width = this.getWidth();
g.setColor(Color.BLACK);
g.fillRect(0, 0, width, this.getHeight());
if (getPolyObject() == null || timeState == null) {
return;
}
int y = 0;
g.setColor(Color.DARK_GRAY);
g.drawLine(0, 0, width, 0);
for (SoundLayer layer : getPolyObject()) {
y += layer.getSoundLayerHeight();
g.drawLine(0, y, width, y);
}
g.drawLine(0, getHeight() - 1, width, getHeight() - 1);
if (timeState.isSnapEnabled()) {
int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
int x = 0;
if (snapPixels <= 0) {
return;
}
int height = getPolyObject().getTotalHeight();
double snapValue = timeState.getSnapValue();
int pixelSecond = timeState.getPixelSecond();
double time;
for (int i = 0; x < width; i++) {
x = (int) ((i * snapValue) * pixelSecond);
g.drawLine(x, 0, x, height);
}
}
}
Aggregations