Search in sources :

Example 16 with SoundObject

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

the class BlueShareRemoteCaller method getSoundObject.

public static SoundObject getSoundObject(SoundObjectOption iOption) throws IOException, XmlRpcException, ParseException {
    Vector v = new Vector();
    String result;
    v.add(new Integer(iOption.getSoundObjectId()));
    result = (String) xrpc.execute("blueShare.getSoundObject", v);
    SoundObject soundObject = null;
    try {
        Document d = new Document(result);
        soundObject = (SoundObject) ObjectUtilities.loadFromXML(d.getRoot(), new HashMap<>());
    } catch (Exception e) {
    }
    return soundObject;
}
Also used : SoundObject(blue.soundObject.SoundObject) Document(electric.xml.Document) Vector(java.util.Vector) IOException(java.io.IOException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) ParseException(electric.xml.ParseException)

Example 17 with SoundObject

use of blue.soundObject.SoundObject 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 18 with SoundObject

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

the class AudioFileRenderer method render.

@Override
public void render(Graphics graphics, SoundObjectView sObjView, int pixelSeconds) {
    Rectangle clip = graphics.getClipBounds();
    Graphics2D g = (Graphics2D) graphics;
    int w = sObjView.getSize().width;
    int h = sObjView.getSize().height;
    Color bgColor;
    Color border1;
    Color border2;
    Color fontColor;
    Color waveColor;
    SoundObject sObj = sObjView.getSoundObject();
    if (sObjView.isSelected()) {
        bgColor = selectedBgColor;
        border1 = selectedBorder1;
        border2 = selectedBorder2;
        fontColor = selectedFontColor;
    } else {
        bgColor = sObj.getBackgroundColor();
        border1 = bgColor.brighter().brighter();
        border2 = bgColor.darker().darker();
        fontColor = isBright(bgColor) ? Color.BLACK : Color.WHITE;
    }
    if (isBright(bgColor)) {
        waveColor = bgColor.brighter().brighter();
    } else {
        waveColor = bgColor.darker().darker();
    }
    g.setPaint(bgColor);
    g.fillRect(clip.x, 2, clip.width, h - 4);
    // Draw Waveform
    g.setPaint(waveColor);
    paintWaveform(g, sObjView, pixelSeconds);
    // DRAW BORDERS
    // if (GeneralSettings.getInstance().isDrawFlatSObjBorders()) {
    // g.setColor(Color.LIGHT_GRAY);
    // g.drawRect(0, 2, w - 1, h - 4);
    // 
    // } else {
    g.setColor(border1);
    g.drawLine(0, 2, w - 1, 2);
    g.drawLine(0, 2, 0, h - 4);
    g.setColor(border2);
    g.drawLine(0, h - 3, w, h - 3);
    g.drawLine(w - 1, h - 3, w - 1, 2);
    // }
    g.setPaint(fontColor);
    if (h >= 20) {
        g.setComposite(AlphaComposite.Src);
        g.setFont(renderFont);
        String[] parts = sObjView.getSoundObject().getName().split("\\\\[n]");
        for (int i = 0; i < parts.length; i++) {
            int y = 15 + (i * Layer.LAYER_HEIGHT);
            g.drawString(parts[i], labelOffset, y);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) Color(java.awt.Color) Rectangle(java.awt.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 19 with SoundObject

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

the class LetterRenderer method render.

@Override
public void render(Graphics graphics, SoundObjectView sObjView, int pixelSeconds) {
    super.render(graphics, sObjView, pixelSeconds);
    Graphics2D g = (Graphics2D) graphics;
    Color boxColor;
    Color fontColor;
    SoundObject sObj = sObjView.getSoundObject();
    if (sObjView.isSelected()) {
        boxColor = selectedBorder2;
        fontColor = selectedFontColor;
    } else {
        Color bgColor = sObj.getBackgroundColor();
        boxColor = bgColor.brighter().brighter();
        int total = bgColor.getRed() + bgColor.getGreen() + bgColor.getBlue();
        if (total > 128 * 3) {
            fontColor = Color.black;
        } else {
            fontColor = Color.white;
        }
    }
    // DRAW BOX
    g.setColor(boxColor);
    g.fillRect(2, 4, 9, 9);
    // DRAW LETTER
    g.setColor(fontColor);
    g.setFont(miniFont);
    g.drawString(letter, 3, 12);
}
Also used : SoundObject(blue.soundObject.SoundObject) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 20 with SoundObject

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

the class ReplaceWithBufferSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    List<Layer> layers = scorePath.getAllLayers();
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    List<Instance> instances = new ArrayList<>();
    ReplaceScoreObjectEdit top = null;
    for (SoundObject sObj : soundObjects) {
        SoundObject replacement = getReplacementObject(buffer, instances);
        replacement.setStartTime(sObj.getStartTime());
        replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
        ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
        layer.remove(sObj);
        layer.add(replacement);
        ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
        if (top == null) {
            top = edit;
        } else {
            top.addEdit(edit);
        }
    }
    // FIXME - this part is not undoable...
    sObjLib.checkAndAddInstanceSoundObjects(instances);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(top);
}
Also used : ScoreController(blue.ui.core.score.ScoreController) BlueData(blue.BlueData) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) ReplaceScoreObjectEdit(blue.ui.core.score.undo.ReplaceScoreObjectEdit) ArrayList(java.util.ArrayList) SoundObjectLibrary(blue.SoundObjectLibrary) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer)

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