Search in sources :

Example 1 with Sound

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

the class SoundObjectExportPane method jbInit.

private void jbInit() throws Exception {
    this.setLayout(new BorderLayout());
    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    soundObjectListPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    categoryPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    cateogriesLabel.setText(BlueSystem.getString("common.categories"));
    categoryPanel.setLayout(new BorderLayout());
    this.add(namePasswordPanel, BorderLayout.NORTH);
    this.add(mainSplitPane, BorderLayout.CENTER);
    this.add(jPanel2, BorderLayout.SOUTH);
    descriptionText.setText(BlueSystem.getString("blueShare.enterDescription"));
    descriptionText.setLineWrap(true);
    descriptionScrollPane.setBorder(new TitledBorder(null, BlueSystem.getString("blueShare.instrDescription")));
    submitButton.setText(BlueSystem.getString("common.submit"));
    soundObjectListPanel.setLayout(new BorderLayout());
    iLabel.setText("SoundObjects from Library");
    // soundObjectLibraryTree.setSelectionModel(TreeSelectionModel.SINGLE_TREE_SELECTION);
    topSplitPane.add(soundObjectListPanel, JSplitPane.LEFT);
    soundObjectListPanel.add(soundObjectListScrollPane, BorderLayout.CENTER);
    soundObjectListPanel.add(iLabel, BorderLayout.NORTH);
    soundObjectListScrollPane.getViewport().add(soundObjectLibraryTree, null);
    descriptionScrollPane.getViewport().add(descriptionText, null);
    jPanel2.add(submitButton, null);
    topSplitPane.setDividerLocation(300);
    mainSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    mainSplitPane.add(topSplitPane, JSplitPane.TOP);
    mainSplitPane.add(descriptionScrollPane, JSplitPane.BOTTOM);
    topSplitPane.add(categoryPanel, JSplitPane.RIGHT);
    categoryPanel.add(cateogriesLabel, BorderLayout.NORTH);
    categoryPanel.add(categoryScrollPane, BorderLayout.CENTER);
    categoryScrollPane.getViewport().add(categoryTree, null);
    mainSplitPane.setDividerLocation(200);
    submitButton.addActionListener((ActionEvent e) -> {
        submitSoundObject();
    });
    soundObjectLibraryTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TreePath path = soundObjectLibraryTree.getSelectionPath();
            if (path == null) {
                descriptionText.setText(SELECT_INSTR_TEXT);
                descriptionText.setEnabled(false);
                return;
            }
            Object userObj = path.getLastPathComponent();
            TreeItem<LibraryItem<SoundObject>> node = (TreeItem<LibraryItem<SoundObject>>) userObj;
            if (!node.isLeaf()) {
                descriptionText.setText(SELECT_INSTR_TEXT);
                descriptionText.setEnabled(false);
                return;
            }
            SoundObject instr = node.getValue().getValue();
            if (instr instanceof Sound) {
                descriptionText.setText(((Sound) instr).getComment());
            } else if (instr instanceof ObjectBuilder) {
                descriptionText.setText(((ObjectBuilder) instr).getComment());
            } else {
                descriptionText.setText("");
            }
            descriptionText.setEnabled(true);
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) LibraryItem(blue.library.LibraryItem) TreeItem(javafx.scene.control.TreeItem) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) Sound(blue.soundObject.Sound) ObjectBuilder(blue.soundObject.ObjectBuilder) TitledBorder(javax.swing.border.TitledBorder) BorderLayout(java.awt.BorderLayout) TreePath(javax.swing.tree.TreePath) SoundObject(blue.soundObject.SoundObject) SoundObject(blue.soundObject.SoundObject)

Example 2 with Sound

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

the class SoundEditor method editScoreObject.

@Override
public final void editScoreObject(ScoreObject sObj) {
    if (sObj == null) {
        this.sObj = null;
        editorLabel.setText("no editor available");
        editor.editInstrument(null);
        return;
    }
    if (!(sObj instanceof Sound)) {
        this.sObj = null;
        editorLabel.setText("no editor available");
        editor.editInstrument(null);
        return;
    }
    if (this.sObj != null) {
        final Sound temp = this.sObj;
        BlueFX.runOnFXThread(() -> {
            temp.commentProperty().unbind();
            temp.removeScoreObjectListener(sObjListener);
        });
    }
    this.sObj = (Sound) sObj;
    editor.editInstrument(this.sObj.getBlueSynthBuilder());
    BlueFX.runOnFXThread(() -> {
        lineList.clear();
        int colorCount = 0;
        for (Parameter p : this.sObj.getBlueSynthBuilder().getParameterList().sorted()) {
            if (p.isAutomationEnabled()) {
                p.getLine().setVarName(p.getName());
                p.getLine().setColor(LineColors.getColor(colorCount++));
                List<LinePoint> points = p.getLine().getObservableList();
                if (points.size() < 2) {
                    LinePoint lp = new LinePoint();
                    lp.setLocation(1.0, points.get(0).getY());
                    points.add(lp);
                }
                lineList.add(p.getLine());
            }
        }
        lineView.setStartTime(this.sObj.getStartTime());
        lineView.setDuration(this.sObj.getSubjectiveDuration());
        commentTextArea.setText(this.sObj.getComment());
        this.sObj.commentProperty().bind(commentTextArea.textProperty());
        this.sObj.addScoreObjectListener(sObjListener);
    });
}
Also used : LinePoint(blue.components.lines.LinePoint) Parameter(blue.automation.Parameter) Sound(blue.soundObject.Sound) LinePoint(blue.components.lines.LinePoint)

Example 3 with Sound

use of blue.soundObject.Sound 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);
}
Also used : BlueData(blue.BlueData) LinePoint(blue.components.lines.LinePoint) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Parameter(blue.automation.Parameter) ScoreObject(blue.score.ScoreObject) Sound(blue.soundObject.Sound) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer)

Aggregations

Sound (blue.soundObject.Sound)3 Parameter (blue.automation.Parameter)2 LinePoint (blue.components.lines.LinePoint)2 BlueData (blue.BlueData)1 SoundLayer (blue.SoundLayer)1 LibraryItem (blue.library.LibraryItem)1 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 ScoreObject (blue.score.ScoreObject)1 Layer (blue.score.layers.Layer)1 ObjectBuilder (blue.soundObject.ObjectBuilder)1 SoundObject (blue.soundObject.SoundObject)1 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)1 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 TreeItem (javafx.scene.control.TreeItem)1 TitledBorder (javax.swing.border.TitledBorder)1 TreePath (javax.swing.tree.TreePath)1