Search in sources :

Example 1 with BlueSynthBuilder

use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.

the class SubChannelListPanel method reconcileNameChangeInBlueArrangement.

/**
 * A hack to explicitly walk the current blue orchestra to find any
 * BlueSynthBuilder's that contain BSBSubChannelDropdown's and to reconcile
 * the name change.
 *
 * @param oldName
 * @param newName
 */
private void reconcileNameChangeInBlueArrangement(String oldName, String newName) {
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    if (data == null) {
        return;
    }
    Arrangement arr = data.getArrangement();
    for (int i = 0; i < arr.size(); i++) {
        Instrument instr = arr.getInstrument(i);
        if (instr instanceof BlueSynthBuilder) {
            BlueSynthBuilder bsb = (BlueSynthBuilder) instr;
            BSBGraphicInterface bsbInterface = bsb.getGraphicInterface();
            for (BSBObject bsbObj : bsbInterface.getAllSet()) {
                if (bsbObj instanceof BSBSubChannelDropdown) {
                    BSBSubChannelDropdown bsbSubDrop = (BSBSubChannelDropdown) bsbObj;
                    if (bsbSubDrop.getChannelOutput().equals(oldName)) {
                        bsbSubDrop.setChannelOutput(newName);
                    }
                }
            }
        }
    }
}
Also used : BlueData(blue.BlueData) BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) BSBObject(blue.orchestra.blueSynthBuilder.BSBObject) BSBSubChannelDropdown(blue.orchestra.blueSynthBuilder.BSBSubChannelDropdown) Instrument(blue.orchestra.Instrument) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) Arrangement(blue.Arrangement)

Example 2 with BlueSynthBuilder

use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.

the class BlueSynthBuilderEditor method editInstrument.

@Override
public void editInstrument(Instrument instr) {
    if (instr == null) {
        this.bsb = null;
        return;
    }
    if (!(instr instanceof BlueSynthBuilder)) {
        this.bsb = null;
        return;
    }
    this.bsb = (BlueSynthBuilder) instr;
    PresetGroup presetGroup = bsb.getPresetGroup();
    BSBGraphicInterface graphicInterface = bsb.getGraphicInterface();
    Platform.runLater(() -> interfaceEditor.editInterface(graphicInterface, presetGroup));
    this.codeEditor.editBlueSynthBuilder(bsb);
    this.udoPanel.editOpcodeList(bsb.getOpcodeList());
}
Also used : BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder)

Example 3 with BlueSynthBuilder

use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.

the class ArrangementEditPanel method pasteInstrument.

public void pasteInstrument() {
    Object obj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT);
    if (obj == null || !(obj instanceof Instrument)) {
        return;
    }
    Instrument instr = (Instrument) obj;
    Instrument clone = (Instrument) instr.deepCopy();
    if (clone instanceof BlueSynthBuilder) {
        ((BlueSynthBuilder) clone).clearParameters();
    }
    addInstrument(clone);
}
Also used : Instrument(blue.orchestra.Instrument) GenericInstrument(blue.orchestra.GenericInstrument) TransferableInstrument(blue.TransferableInstrument) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder)

Example 4 with BlueSynthBuilder

use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.

the class ArrangementEditPanel method convertToBSB.

public void convertToBSB() {
    int selectedRow = arrangementTable.getSelectedRow();
    if (selectedRow < 0) {
        return;
    }
    String instrumentId = (String) arrangement.getValueAt(selectedRow, 1);
    Instrument instr = arrangement.getInstrument(selectedRow);
    if (instr instanceof GenericInstrument) {
        GenericInstrument genInstr = (GenericInstrument) instr;
        BlueSynthBuilder bsb = new BlueSynthBuilder();
        bsb.setName(genInstr.getName());
        bsb.setComment(genInstr.getComment());
        bsb.setGlobalOrc(genInstr.getGlobalOrc());
        bsb.setGlobalSco(genInstr.getGlobalSco());
        bsb.setInstrumentText(genInstr.getText());
        bsb.setOpcodeList(genInstr.getOpcodeList());
        arrangement.replaceInstrument(instrumentId, bsb);
    }
}
Also used : Instrument(blue.orchestra.Instrument) GenericInstrument(blue.orchestra.GenericInstrument) TransferableInstrument(blue.TransferableInstrument) GenericInstrument(blue.orchestra.GenericInstrument) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) Point(java.awt.Point)

Example 5 with BlueSynthBuilder

use of blue.orchestra.BlueSynthBuilder in project blue by kunstmusik.

the class InstrumentTreeDropTarget method drop.

@Override
public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    Object node = parentpath.getLastPathComponent();
    if (dtde.isDataFlavorSupported(TransferableInstrument.INSTR_CAT_FLAVOR)) {
        if (!(node instanceof InstrumentCategory)) {
            dtde.rejectDrop();
            return;
        }
        if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
            dtde.acceptDrop(dtde.getDropAction());
            Transferable tr = dtde.getTransferable();
            try {
                Object transferNode = tr.getTransferData(TransferableInstrument.INSTR_CAT_FLAVOR);
                InstrumentLibrary iLibrary = (InstrumentLibrary) tree.getModel();
                InstrumentCategory parentNode = (InstrumentCategory) node;
                InstrumentCategory instrumentCategory = (InstrumentCategory) transferNode;
                // iLibrary.removeCategory(instrumentCategory);
                iLibrary.addCategory(parentNode, instrumentCategory);
                dtde.dropComplete(true);
            } catch (UnsupportedFlavorException | IOException e) {
                dtde.dropComplete(false);
            }
        } else {
            dtde.rejectDrop();
        }
    } else if (dtde.isDataFlavorSupported(TransferableInstrument.INSTR_FLAVOR)) {
        dtde.acceptDrop(dtde.getDropAction());
        try {
            Transferable tr = dtde.getTransferable();
            Object transferNode = tr.getTransferData(TransferableInstrument.INSTR_FLAVOR);
            Instrument instrument = (Instrument) transferNode;
            InstrumentLibrary iLibrary = (InstrumentLibrary) tree.getModel();
            if (instrument instanceof BlueSynthBuilder) {
                ((BlueSynthBuilder) instrument).clearParameters();
            }
            // iLibrary.removeInstrument(instrument);
            if (node instanceof InstrumentCategory) {
                InstrumentCategory parentNode = (InstrumentCategory) node;
                iLibrary.addInstrument(parentNode, instrument);
            } else if (node instanceof Instrument) {
                InstrumentCategory parentNode = (InstrumentCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);
                int index = ListUtil.indexOfByRef(parentNode.getInstruments(), node);
                int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);
                Rectangle bounds = tree.getRowBounds(closestRow);
                if (pt.y > bounds.y + bounds.height) {
                    iLibrary.addInstrument(parentNode, instrument);
                } else {
                    iLibrary.addInstrument(parentNode, index, instrument);
                }
            }
            dtde.dropComplete(true);
        } catch (UnsupportedFlavorException | IOException e) {
            dtde.dropComplete(false);
        }
    } else {
        dtde.rejectDrop();
    }
}
Also used : DropTargetContext(java.awt.dnd.DropTargetContext) Transferable(java.awt.datatransfer.Transferable) Rectangle(java.awt.Rectangle) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) Point(java.awt.Point) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) Point(java.awt.Point) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) InstrumentLibrary(blue.InstrumentLibrary) Instrument(blue.orchestra.Instrument) InstrumentCategory(blue.orchestra.InstrumentCategory)

Aggregations

BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)7 Instrument (blue.orchestra.Instrument)5 BlueData (blue.BlueData)3 BSBGraphicInterface (blue.orchestra.blueSynthBuilder.BSBGraphicInterface)3 Arrangement (blue.Arrangement)2 TransferableInstrument (blue.TransferableInstrument)2 GenericInstrument (blue.orchestra.GenericInstrument)2 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)2 BSBSubChannelDropdown (blue.orchestra.blueSynthBuilder.BSBSubChannelDropdown)2 Point (java.awt.Point)2 InstrumentLibrary (blue.InstrumentLibrary)1 SoundLayer (blue.SoundLayer)1 Parameter (blue.automation.Parameter)1 LinePoint (blue.components.lines.LinePoint)1 InstrumentCategory (blue.orchestra.InstrumentCategory)1 PresetGroup (blue.orchestra.blueSynthBuilder.PresetGroup)1 ScoreObject (blue.score.ScoreObject)1 Layer (blue.score.layers.Layer)1 Sound (blue.soundObject.Sound)1 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)1