Search in sources :

Example 6 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class PatternLayerPanel method setSObjFromBufferMenuItemActionPerformed.

// GEN-LAST:event_editSObjMenuItemActionPerformed
private void setSObjFromBufferMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_setSObjFromBufferMenuItemActionPerformed
    ScoreController controller = ScoreController.getInstance();
    ScoreController.ScoreObjectBuffer buffer = controller.getScoreObjectBuffer();
    if (buffer.scoreObjects.size() == 1) {
        ScoreObject scoreObj = buffer.scoreObjects.get(0);
        if (!(scoreObj instanceof SoundObject)) {
            return;
        }
        SoundObject sObj = (SoundObject) scoreObj;
        SoundObject copy = sObj.deepCopy();
        copy.setStartTime(0.0f);
        copy.setSubjectiveDuration(4);
        copy.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
        patternLayer.setSoundObject(copy);
        editSoundObject();
    }
}
Also used : ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject) ScoreObject(blue.score.ScoreObject)

Example 7 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class SoundObjectLibraryTopComponent method removeButtonActionPerformed.

// GEN-LAST:event_copyInstanceButtonActionPerformed
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_removeButtonActionPerformed
    if (sObjLibTable.getSelectedRow() != -1) {
        NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation("Removing this SoundObject will remove all Instances of it " + "within your project.  Please confirm this operation. (This " + "can not be undone.)", NotifyDescriptor.YES_NO_CANCEL_OPTION);
        Object retVal = DialogDisplayer.getDefault().notify(descriptor);
        if (retVal == NotifyDescriptor.YES_OPTION) {
            SoundObject sObj = sObjLib.getSoundObject(sObjLibTable.getSelectedRow());
            SoundObjectLibraryUtils.removeLibrarySoundObject(BlueProjectManager.getInstance().getCurrentBlueData(), sObj);
            // sObjEditPanel.editSoundObject(null);
            fireSoundObjectRemoved((SoundObject) sObj);
            sObjLibTable.revalidate();
        }
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) SoundObject(blue.soundObject.SoundObject) SoundObject(blue.soundObject.SoundObject)

Example 8 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class SoundObjectPropertiesTopComponent method updateRepeatPoint.

protected void updateRepeatPoint() {
    if (!(sObj instanceof ScoreObject)) {
        return;
    }
    SoundObject soundObj = (SoundObject) sObj;
    double initialRepeatPoint = soundObj.getRepeatPoint();
    double newValue;
    try {
        newValue = Double.parseDouble(repeatePointText.getText());
    } catch (NumberFormatException nfe) {
        repeatePointText.setText(Double.toString(initialRepeatPoint));
        return;
    }
    if (newValue <= 0.0f) {
        repeatePointText.setText(Double.toString(initialRepeatPoint));
        return;
    } else {
        soundObj.setRepeatPoint(newValue);
        repeatePointText.setText(Double.toString(newValue));
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) ScoreObject(blue.score.ScoreObject)

Example 9 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class SoundObjectPropertiesTopComponent method updateUseRepeatPoint.

private void updateUseRepeatPoint() {
    if (!(sObj instanceof ScoreObject)) {
        return;
    }
    SoundObject soundObj = (SoundObject) sObj;
    repeatePointText.setEnabled(useRepeatPoint.isSelected());
    if (!isUpdating) {
        double dur = -1.0f;
        if (useRepeatPoint.isSelected()) {
            dur = sObj.getSubjectiveDuration();
        }
        soundObj.setRepeatPoint(dur);
        repeatePointText.setText(Double.toString(dur));
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) ScoreObject(blue.score.ScoreObject)

Example 10 with SoundObject

use of blue.soundObject.SoundObject in project blue by kunstmusik.

the class UserSoundObjectLibrary method buildContextMenu.

public ContextMenu buildContextMenu(TreeView<LibraryItem<SoundObject>> treeView) {
    ContextMenu popupMenu = new ContextMenu();
    // popupMenu.getItems().add(new MenuItem("Test"));
    ObservableList<TreeItem<LibraryItem<SoundObject>>> selectedItems = treeView.getSelectionModel().getSelectedItems();
    final ScoreController.ScoreObjectBuffer scoreObjectBuffer = ScoreController.getInstance().getScoreObjectBuffer();
    // FOLDER MENU ITEMS
    List<MenuItem> folderMenuItems = new ArrayList<>();
    MenuItem addFolder = new MenuItem("Add Folder");
    addFolder.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getChildren().add(new LibraryTreeItem(new LibraryItem<>("New Folder")));
    });
    MenuItem deleteFolder = new MenuItem("Delete Folder");
    deleteFolder.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getParent().getChildren().remove(item);
    });
    MenuItem paste = new MenuItem("Paste SoundObject");
    paste.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0).deepCopy();
        if (!SoundObjectUtilities.isOrContainsInstance(sObj)) {
            item.getChildren().add(new LibraryTreeItem(new LibraryItem<>(sObj)));
        }
    });
    folderMenuItems.add(addFolder);
    folderMenuItems.add(deleteFolder);
    folderMenuItems.add(paste);
    // FOLDER MENU ITEMS
    List<MenuItem> sObjMenuItems = new ArrayList<>();
    MenuItem cut = new MenuItem("Cut");
    cut.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = item.getValue().getValue();
        if (sObj == null) {
            return;
        }
        scoreObjectBuffer.clear();
        scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
        scoreObjectBuffer.layerIndexes.add(0);
        item.getParent().getChildren().remove(item);
    });
    MenuItem copy = new MenuItem("Copy");
    copy.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        SoundObject sObj = item.getValue().getValue();
        if (sObj == null) {
            return;
        }
        scoreObjectBuffer.clear();
        scoreObjectBuffer.scoreObjects.add(sObj.deepCopy());
        scoreObjectBuffer.layerIndexes.add(0);
    });
    MenuItem delete = new MenuItem("Delete");
    delete.setOnAction(evt -> {
        TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
        item.getParent().getChildren().remove(item);
    });
    sObjMenuItems.add(cut);
    sObjMenuItems.add(copy);
    sObjMenuItems.add(new SeparatorMenuItem());
    sObjMenuItems.add(delete);
    popupMenu.getItems().addAll(folderMenuItems);
    popupMenu.getItems().addAll(sObjMenuItems);
    popupMenu.setOnShowing(evt -> {
        if (selectedItems.size() == 1) {
            TreeItem<LibraryItem<SoundObject>> item = selectedItems.get(0);
            boolean isFolder = item.getValue().getValue() == null;
            deleteFolder.setDisable(item == soundObjectLibrary.getRoot());
            if (isFolder) {
                boolean isScoreObj = scoreObjectBuffer.scoreObjects.size() == 1 && scoreObjectBuffer.scoreObjects.get(0) instanceof SoundObject;
                if (isScoreObj) {
                    SoundObject sObj = (SoundObject) scoreObjectBuffer.scoreObjects.get(0);
                    paste.setDisable(SoundObjectUtilities.isOrContainsInstance(sObj));
                } else {
                    paste.setDisable(true);
                }
            }
            for (MenuItem menuItem : folderMenuItems) {
                menuItem.setVisible(isFolder);
            }
            for (MenuItem menuItem : sObjMenuItems) {
                menuItem.setVisible(!isFolder);
            }
        }
    });
    return popupMenu;
}
Also used : LibraryItem(blue.library.LibraryItem) LibraryTreeItem(blue.library.LibraryTreeItem) TreeItem(javafx.scene.control.TreeItem) LibraryTreeItem(blue.library.LibraryTreeItem) ArrayList(java.util.ArrayList) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject)

Aggregations

SoundObject (blue.soundObject.SoundObject)53 SoundLayer (blue.SoundLayer)12 Instance (blue.soundObject.Instance)11 PolyObject (blue.soundObject.PolyObject)11 ScoreObject (blue.score.ScoreObject)8 ArrayList (java.util.ArrayList)8 Element (electric.xml.Element)7 Point (java.awt.Point)7 IOException (java.io.IOException)6 BlueData (blue.BlueData)5 Layer (blue.score.layers.Layer)5 NoteList (blue.soundObject.NoteList)5 ScoreController (blue.ui.core.score.ScoreController)5 HashMap (java.util.HashMap)5 SoundObjectLibrary (blue.SoundObjectLibrary)4 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)4 Document (electric.xml.Document)4 ParseException (electric.xml.ParseException)4 File (java.io.File)4 LiveObject (blue.blueLive.LiveObject)3