Search in sources :

Example 11 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class ResizeScoreObjectsListener method mousePressed.

@Override
public void mousePressed(MouseEvent e) {
    Cursor c = scoreTC.getScorePanel().getCursor();
    if (currentScoreObjectView == null || c == null || !(c.getType() == Cursor.E_RESIZE_CURSOR || c.getType() == Cursor.W_RESIZE_CURSOR)) {
        return;
    }
    e.consume();
    ScoreObject scoreObj = currentScoreObjectView.getScoreObject();
    Collection<? extends ScoreObject> temp = ScoreController.getInstance().getSelectedScoreObjects();
    if (temp.size() != 1) {
        // revisit to do more than one in the future
        return;
    }
    switch(c.getType()) {
        case Cursor.W_RESIZE_CURSOR:
            resizeMode = ResizeMode.RESIZE_RIGHT;
            break;
        case Cursor.E_RESIZE_CURSOR:
            resizeMode = ResizeMode.RESIZE_LEFT;
            break;
        default:
            throw new RuntimeException("Error: Unknown resize type: " + c.getType());
    }
    startPoint = e.getPoint();
    selectedScoreObjects = temp.toArray(new ScoreObject[0]);
    startTimes = new double[selectedScoreObjects.length];
    endTimes = new double[selectedScoreObjects.length];
    minDiffTime = Double.MAX_VALUE;
    maxDiffTime = Double.MIN_VALUE;
    for (int i = 0; i < selectedScoreObjects.length; i++) {
        final ScoreObject sObj = selectedScoreObjects[i];
        startTimes[i] = sObj.getStartTime();
        endTimes[i] = startTimes[i] + sObj.getSubjectiveDuration();
        if (sObj.getMaxResizeLeftDiff() < minDiffTime) {
            minDiffTime = sObj.getMaxResizeLeftDiff();
        }
        if (sObj.getMaxResizeRightDiff() > maxDiffTime) {
            maxDiffTime = sObj.getMaxResizeRightDiff();
        }
    }
}
Also used : ScoreObject(blue.score.ScoreObject) Cursor(java.awt.Cursor) Point(java.awt.Point)

Example 12 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class AlignLeftAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (selected.size() < 2) {
        return;
    }
    double[] initialStartTimes = new double[selected.size()];
    double[] endingStartTimes = new double[selected.size()];
    double farLeft = Double.MAX_VALUE;
    int i = 0;
    for (ScoreObject scoreObj : selected) {
        initialStartTimes[i] = scoreObj.getStartTime();
        if (initialStartTimes[i] < farLeft) {
            farLeft = initialStartTimes[i];
        }
        i++;
    }
    i = 0;
    for (ScoreObject scoreObj : selected) {
        scoreObj.setStartTime(farLeft);
        endingStartTimes[i] = farLeft;
        i++;
    }
    BlueUndoManager.setUndoManager("score");
    AlignEdit edit = new AlignEdit(selected.toArray(new ScoreObject[0]), initialStartTimes, endingStartTimes);
    edit.setPresentationName("Align Left");
    BlueUndoManager.addEdit(edit);
}
Also used : AlignEdit(blue.ui.core.score.undo.AlignEdit) ScoreObject(blue.score.ScoreObject)

Example 13 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class AlignRightAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    if (selected.size() < 2) {
        return;
    }
    double[] initialStartTimes = new double[selected.size()];
    double[] endingStartTimes = new double[selected.size()];
    double farRight = Double.MIN_VALUE;
    int i = 0;
    for (ScoreObject scoreObj : selected) {
        initialStartTimes[i] = scoreObj.getStartTime();
        double end = initialStartTimes[i] + scoreObj.getSubjectiveDuration();
        if (end > farRight) {
            farRight = end;
        }
        i++;
    }
    i = 0;
    for (ScoreObject scoreObj : selected) {
        double newTime = farRight - scoreObj.getSubjectiveDuration();
        scoreObj.setStartTime(newTime);
        endingStartTimes[i] = newTime;
        i++;
    }
    BlueUndoManager.setUndoManager("score");
    AlignEdit edit = new AlignEdit(selected.toArray(new ScoreObject[0]), initialStartTimes, endingStartTimes);
    edit.setPresentationName("Align Right");
    BlueUndoManager.addEdit(edit);
}
Also used : AlignEdit(blue.ui.core.score.undo.AlignEdit) ScoreObject(blue.score.ScoreObject)

Example 14 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class RealtimeRenderManager method auditionSoundObjects.

public void auditionSoundObjects(BlueData data, List<ScoreObject> scoreObjects) {
    if (scoreObjects == null || scoreObjects.isEmpty()) {
        return;
    }
    if (isRendering()) {
        stopRendering();
    }
    BlueData tempData = new BlueData(data);
    tempData.setLoopRendering(false);
    List<PolyObject> path = null;
    filterScore(tempData.getScore(), scoreObjects);
    if (data.getScore().isEmpty()) {
        throw new RuntimeException("Error: unable to find root LayerGroups for objects...");
    }
    double minTime = Double.MAX_VALUE;
    double maxTime = Double.MIN_VALUE;
    for (ScoreObject sObj : scoreObjects) {
        double startTime = sObj.getStartTime();
        double endTime = startTime + sObj.getSubjectiveDuration();
        if (startTime < minTime) {
            minTime = startTime;
        }
        if (endTime > maxTime) {
            maxTime = endTime;
        }
    }
    Mixer m = tempData.getMixer();
    if (m.isEnabled()) {
        maxTime += m.getExtraRenderTime();
    }
    tempData.setRenderStartTime(minTime);
    tempData.setRenderEndTime(maxTime);
    renderProject(tempData, true);
}
Also used : BlueData(blue.BlueData) Mixer(blue.mixer.Mixer) ScoreObject(blue.score.ScoreObject) PolyObject(blue.soundObject.PolyObject)

Example 15 with ScoreObject

use of blue.score.ScoreObject in project blue by kunstmusik.

the class MoveScoreObjectsListenerTest method testGetMaxYAdjust.

/**
 * Test of getMaxYAdjust method, of class MoveScoreObjectsListener.
 */
@Test
public void testGetMaxYAdjust() {
    System.out.println("getMaxYAdjust");
    List<Layer> layers = new ArrayList<>();
    final SoundLayer soundLayer = new SoundLayer();
    ScoreObject scoreObj = new GenericScore();
    soundLayer.add((SoundObject) scoreObj);
    layers.add(new SoundLayer());
    layers.add(soundLayer);
    layers.add(new SoundLayer());
    int sObjLayerIndex = 1;
    int result = MoveScoreObjectsListener.getMaxYAdjust(layers, scoreObj, sObjLayerIndex);
    assertEquals(1, result);
    layers.add(0, new InvalidLayer());
    layers.add(1, new SoundLayer());
    layers.add(new InvalidLayer());
    sObjLayerIndex = 3;
    result = MoveScoreObjectsListener.getMaxYAdjust(layers, scoreObj, sObjLayerIndex);
    assertEquals(1, result);
}
Also used : SoundLayer(blue.SoundLayer) ArrayList(java.util.ArrayList) ScoreObject(blue.score.ScoreObject) GenericScore(blue.soundObject.GenericScore) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer) Test(org.junit.Test)

Aggregations

ScoreObject (blue.score.ScoreObject)39 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)13 Layer (blue.score.layers.Layer)12 ArrayList (java.util.ArrayList)9 Point (java.awt.Point)8 BlueData (blue.BlueData)6 SoundObject (blue.soundObject.SoundObject)6 ScorePath (blue.ui.core.score.ScorePath)6 SoundLayer (blue.SoundLayer)5 AlignEdit (blue.ui.core.score.undo.AlignEdit)5 Instance (blue.soundObject.Instance)4 PolyObject (blue.soundObject.PolyObject)4 ScoreController (blue.ui.core.score.ScoreController)4 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)4 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)4 SoundObjectLibrary (blue.SoundObjectLibrary)2 AlphaMarquee (blue.components.AlphaMarquee)2 Score (blue.score.Score)2 GenericScore (blue.soundObject.GenericScore)2 Test (org.junit.Test)2