Search in sources :

Example 1 with Arrangement

use of blue.Arrangement in project blue by kunstmusik.

the class AutomationManager method getAutomationMenu.

public JPopupMenu getAutomationMenu(ParameterIdList paramIdList) {
    this.selectedParamIdList = paramIdList;
    // if (menu == null || dirty) {
    JPopupMenu menu = new JPopupMenu();
    // Build Instrument Menu
    JMenu instrRoot = new JMenu("Instrument");
    MenuScroller.setScrollerFor(instrRoot);
    Arrangement arrangement = data.getArrangement();
    for (int i = 0; i < arrangement.size(); i++) {
        InstrumentAssignment ia = arrangement.getInstrumentAssignment(i);
        if (ia.enabled && ia.instr instanceof Automatable) {
            ParameterList params = ((Automatable) ia.instr).getParameterList();
            if (params.size() <= 0) {
                continue;
            }
            final JMenu instrMenu = new JMenu();
            MenuScroller.setScrollerFor(instrMenu);
            instrMenu.setText(ia.arrangementId + ") " + ia.instr.getName());
            for (Parameter param : params.sorted()) {
                JMenuItem paramItem = new JMenuItem();
                paramItem.setText(param.getName());
                paramItem.addActionListener(parameterActionListener);
                if (param.isAutomationEnabled()) {
                    if (paramIdList.contains(param.getUniqueId())) {
                        paramItem.setForeground(Color.GREEN);
                    } else {
                        paramItem.setForeground(Color.ORANGE);
                    }
                }
                paramItem.putClientProperty("instr", ia.instr);
                paramItem.putClientProperty("param", param);
                instrMenu.add(paramItem);
            }
            instrRoot.add(instrMenu);
        }
    }
    menu.add(instrRoot);
    // Build Mixer Menu
    Mixer mixer = data.getMixer();
    if (mixer.isEnabled()) {
        JMenu mixerRoot = new JMenu("Mixer");
        MenuScroller.setScrollerFor(mixerRoot);
        // add channels
        ChannelList channels = mixer.getChannels();
        if (channels.size() > 0) {
            JMenu channelsMenu = new JMenu("Channels");
            for (int i = 0; i < channels.size(); i++) {
                channelsMenu.add(buildChannelMenu(channels.get(i), paramIdList));
            }
            mixerRoot.add(channelsMenu);
        }
        // add subchannels
        ChannelList subChannels = mixer.getSubChannels();
        if (subChannels.size() > 0) {
            JMenu subChannelsMenu = new JMenu("Sub-Channels");
            for (int i = 0; i < subChannels.size(); i++) {
                subChannelsMenu.add(buildChannelMenu(subChannels.get(i), paramIdList));
            }
            mixerRoot.add(subChannelsMenu);
        }
        // add master channel
        Channel master = mixer.getMaster();
        mixerRoot.add(buildChannelMenu(master, paramIdList));
        menu.add(mixerRoot);
    }
    menu.addSeparator();
    JMenuItem clearAll = new JMenuItem("Clear All");
    clearAll.addActionListener((ActionEvent e) -> {
        Object retVal = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation("Please Confirm Clearing All Parameter Data for this SoundLayer"));
        if (retVal == NotifyDescriptor.YES_OPTION) {
            ParameterIdList idList = selectedParamIdList;
            for (String paramId : idList.getParameters()) {
                Parameter param = getParameter(paramId);
                param.setAutomationEnabled(false);
                idList.removeParameterId(paramId);
            }
        }
    });
    menu.add(clearAll);
    clearAll.setEnabled(selectedParamIdList.size() > 0);
    // System.err.println(parameterMap);
    return menu;
}
Also used : ActionEvent(java.awt.event.ActionEvent) Mixer(blue.mixer.Mixer) Channel(blue.mixer.Channel) JPopupMenu(javax.swing.JPopupMenu) Arrangement(blue.Arrangement) NotifyDescriptor(org.openide.NotifyDescriptor) InstrumentAssignment(blue.InstrumentAssignment) PolyObject(blue.soundObject.PolyObject) JMenuItem(javax.swing.JMenuItem) ChannelList(blue.mixer.ChannelList) JMenu(javax.swing.JMenu)

Example 2 with Arrangement

use of blue.Arrangement in project blue by kunstmusik.

the class CSDRender method generateCSDImpl.

@Override
protected CsdRenderResult generateCSDImpl(BlueData data, double startTime, double endTime, boolean isRealTime, boolean _usingAPI) {
    ProjectPluginManager.getInstance().preRender(data);
    StringChannelNameManager scnm = new StringChannelNameManager();
    ParameterNameManager pnm = new ParameterNameManager();
    ArrayList<StringChannel> stringChannels = getStringChannels(data.getArrangement(), scnm);
    ParameterHelper.clearCompilationVarNames(data);
    boolean usingAPI = isRealTime && _usingAPI;
    double renderStartTime = data.getRenderStartTime();
    // making copies to use for adding compileTime tables and instruments
    Tables tables = new Tables(data.getTableSet());
    ArrayList originalParameters;
    // if (usingAPI) {
    originalParameters = ParameterHelper.getAllParameters(data.getArrangement(), data.getMixer());
    // } else {
    // originalParameters = ParameterHelper.getActiveParameters(
    // data.getArrangement(), data.getMixer());
    // }
    assignParameterNames(originalParameters, pnm);
    Arrangement arrangement = new Arrangement(data.getArrangement());
    arrangement.clearUnusedInstrAssignments();
    boolean hasInstruments = arrangement.size() > 0;
    CompileData compileData = new CompileData(arrangement, tables, stringChannels, originalParameters, scnm, pnm);
    Mixer mixer = null;
    boolean mixerEnabled = data.getMixer().isEnabled();
    if (mixerEnabled) {
        mixer = new Mixer(data.getMixer());
        assignChannelIds(compileData, mixer);
    }
    NoteList generatedNotes;
    try {
        generatedNotes = data.getScore().generateForCSD(compileData, startTime, endTime);
    } catch (ScoreGenerationException ex) {
        throw new RuntimeException(ex);
    }
    compileData.setHandleParametersAndChannels(false);
    // assignParameterNames(originalParameters);
    // get parameters
    // ArrayList parameters;
    // if (usingAPI) {
    // parameters = ParameterHelper.getAllParameters(
    // arrangement, mixer);
    // } else {
    // parameters = ParameterHelper.getActiveParameters(
    // arrangement, mixer);
    // }
    GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
    OpcodeList udos = new OpcodeList(data.getOpcodeList());
    // add all UDO's from instruments and effects
    arrangement.generateUserDefinedOpcodes(udos);
    // adding all compile-time instruments from soundObjects to arrangement
    appendFtgenTableNumbers(globalOrcSco.getGlobalOrc(), tables);
    // generating ftables
    arrangement.generateFTables(tables);
    String ftables = tables.getTables();
    // Handle Render End Instrument and Note
    if (endTime > 0.0f && endTime > startTime) {
        Instrument instr = createRenderEndInstrument();
        int instrId = arrangement.addInstrument(instr);
        double endStartTime = endTime - startTime;
        try {
            Note renderEndNote = Note.createNote("i" + instrId + " " + endStartTime + " 0.1");
            generatedNotes.add(renderEndNote);
        } catch (NoteParseException e1) {
        }
    }
    Tempo tempo = data.getScore().getTempo();
    TempoMapper tempoMapper = null;
    if (tempo.isEnabled()) {
        tempoMapper = getTempoMapper(tempo);
        globalOrcSco.appendGlobalSco(getTempoScore(tempo, renderStartTime, endTime));
    } else {
        tempoMapper = getTempoMapper(globalOrcSco.getGlobalSco());
    }
    double totalDur = blue.utility.ScoreUtilities.getTotalDuration(generatedNotes);
    // double processingStart = blue.utility.ScoreUtilities.getProcessingStartTime(
    // tempPObj);
    // FIXME - figure out what to do about PROCESSING_START
    double processingStart = renderStartTime;
    System.out.println("<TOTAL_DUR> = " + totalDur);
    System.out.println("<RENDER_START> = " + renderStartTime);
    System.out.println("<PROCESSING_START> = " + processingStart);
    int nchnls = getNchnls(data, isRealTime);
    ArrayList<Instrument> alwaysOnInstruments = new ArrayList<>();
    // boolean generateMixer = mixerEnabled && (hasInstruments || mixer.hasSubChannelDependencies());
    arrangement.preGenerateOrchestra(compileData, mixer, nchnls, alwaysOnInstruments);
    String globalSco = globalOrcSco.getGlobalSco() + "\n";
    globalSco += arrangement.generateGlobalSco(compileData) + "\n";
    globalSco = preprocessSco(globalSco, totalDur, renderStartTime, processingStart, tempoMapper);
    double globalDur;
    try {
        globalDur = getGlobalDuration(globalSco);
    } catch (SoundObjectException ex) {
        throw new RuntimeException(ex);
    }
    if (globalDur < totalDur) {
        globalDur = totalDur;
    }
    System.out.println("Global Duration = " + globalDur);
    if (mixerEnabled) {
        globalDur += mixer.getExtraRenderTime();
    }
    for (Instrument instrument : alwaysOnInstruments) {
        String sourceId = compileData.getInstrSourceId(instrument);
        String noteStr;
        if (StringUtils.isNumeric(sourceId)) {
            int instrId = arrangement.addInstrumentAtEnd(instrument);
            noteStr = "i" + instrId + " 0 " + totalDur;
        } else {
            String instrId = sourceId + "_alwaysOn";
            arrangement.addInstrumentWithId(instrument, instrId, false);
            noteStr = "i \"" + instrId + "\" 0 " + totalDur;
        }
        try {
            Note n = Note.createNote(noteStr);
            generatedNotes.add(n);
        } catch (NoteParseException ex) {
            ex.printStackTrace();
        }
    }
    if (mixerEnabled) {
        final String mixerId = "BlueMixer";
        // globalDur += mixer.getExtraRenderTime();
        clearUnusedMixerChannels(mixer, arrangement);
        globalOrcSco.appendGlobalOrc(mixer.getInitStatements(compileData, nchnls) + "\n");
        arrangement.addInstrumentWithId(mixer.getMixerInstrument(compileData, udos, nchnls), mixerId, false);
        try {
            Note n = Note.createNote("i \"BlueMixer\" 0 " + globalDur);
            generatedNotes.add(n);
        } catch (NoteParseException ex) {
            ex.printStackTrace();
        }
    }
    handleParameters(originalParameters, stringChannels, globalOrcSco, generatedNotes, arrangement, startTime, startTime + globalDur, isRealTime, _usingAPI);
    if (isRealTime && !usingAPI) {
        Instrument instr = createBlueTimePointerInstrument();
        int instrId = arrangement.addInstrument(instr);
        try {
            Note n = Note.createNote("i" + instrId + " 0 " + globalDur);
            generatedNotes.add(n);
        } catch (NoteParseException ex) {
            ex.printStackTrace();
        }
    }
    String tempGlobalOrc = compileData.getGlobalOrc();
    if (tempGlobalOrc != null && tempGlobalOrc.length() > 0) {
        globalOrcSco.appendGlobalOrc(tempGlobalOrc);
    }
    StrBuilder csd = new StrBuilder();
    appendProjectInfo(data, csd);
    csd.append("<CsoundSynthesizer>\n\n");
    appendCsInstruments(compileData, data, udos, arrangement, globalOrcSco, csd, mixer, isRealTime);
    appendCsScore(globalSco, ftables, generatedNotes, totalDur, csd);
    csd.append("</CsoundSynthesizer>");
    CsdRenderResult renderResult = new CsdRenderResult(csd.toString(), tempoMapper, originalParameters, stringChannels);
    return renderResult;
}
Also used : GlobalOrcSco(blue.GlobalOrcSco) NoteList(blue.soundObject.NoteList) NoteParseException(blue.soundObject.NoteParseException) Mixer(blue.mixer.Mixer) ArrayList(java.util.ArrayList) SoundObjectException(blue.soundObject.SoundObjectException) Tables(blue.Tables) CompileData(blue.CompileData) StrBuilder(org.apache.commons.lang3.text.StrBuilder) StringChannel(blue.orchestra.blueSynthBuilder.StringChannel) Arrangement(blue.Arrangement) LinePoint(blue.components.lines.LinePoint) TempoMapper(blue.noteProcessor.TempoMapper) Tempo(blue.score.tempo.Tempo) ParameterNameManager(blue.automation.ParameterNameManager) ScoreGenerationException(blue.score.ScoreGenerationException) OpcodeList(blue.udo.OpcodeList) StringChannelNameManager(blue.orchestra.blueSynthBuilder.StringChannelNameManager) Note(blue.soundObject.Note) Instrument(blue.orchestra.Instrument) GenericInstrument(blue.orchestra.GenericInstrument) CsdRenderResult(blue.services.render.CsdRenderResult)

Example 3 with Arrangement

use of blue.Arrangement in project blue by kunstmusik.

the class ParameterHelper method clearCompilationVarNames.

public static void clearCompilationVarNames(BlueData data) {
    Arrangement arrangement = data.getArrangement();
    for (int i = 0; i < arrangement.size(); i++) {
        Instrument instr = arrangement.getInstrument(i);
        if (instr instanceof Automatable) {
            Automatable temp = (Automatable) instr;
            temp.getParameterList().clearCompilationVarNames();
        }
    }
    Mixer mixer = data.getMixer();
    List<Channel> channels = mixer.getAllSourceChannels();
    for (Channel channel : channels) {
        clearChannelCompilationVar(channel);
    }
    ChannelList subChannels = mixer.getSubChannels();
    for (Channel subChannel : subChannels) {
        clearChannelCompilationVar(subChannel);
    }
    clearChannelCompilationVar(mixer.getMaster());
}
Also used : Mixer(blue.mixer.Mixer) Channel(blue.mixer.Channel) Instrument(blue.orchestra.Instrument) ChannelList(blue.mixer.ChannelList) Arrangement(blue.Arrangement) Automatable(blue.automation.Automatable)

Example 4 with Arrangement

use of blue.Arrangement 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 5 with Arrangement

use of blue.Arrangement in project blue by kunstmusik.

the class PolyObjectEditor method testSoundObject.

public final void testSoundObject() {
    if (this.pObj == null) {
        return;
    }
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    if (data == null) {
        System.err.println("PolyObjectEditor::testSoundObject() - " + "Could not get reference to current BlueData object");
        return;
    }
    Tables tables = new Tables(data.getTableSet());
    Arrangement arrangement = new Arrangement(data.getArrangement());
    PolyObject tempPObj = new PolyObject(this.pObj);
    OpcodeList opcodeList = new OpcodeList(data.getOpcodeList());
    GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
    // adding all compile-time instruments from soundObjects to arrangement
    arrangement.generateFTables(tables);
    CompileData compileData = new CompileData(arrangement, tables);
    // grabbing all notes from soundObjects
    NoteList generatedNotes = null;
    try {
        generatedNotes = tempPObj.generateForCSD(compileData, 0.0f, -1.0f);
    } catch (Exception e) {
        Exceptions.printStackTrace(e);
        return;
    }
    if (generatedNotes != null) {
        InfoDialog.showInformationDialog(SwingUtilities.getRoot(this), generatedNotes.toString(), BlueSystem.getString("soundObject.generatedScore"));
    }
}
Also used : BlueData(blue.BlueData) GlobalOrcSco(blue.GlobalOrcSco) NoteList(blue.soundObject.NoteList) OpcodeList(blue.udo.OpcodeList) Tables(blue.Tables) Arrangement(blue.Arrangement) PolyObject(blue.soundObject.PolyObject) CompileData(blue.CompileData)

Aggregations

Arrangement (blue.Arrangement)9 Instrument (blue.orchestra.Instrument)6 Mixer (blue.mixer.Mixer)5 OpcodeList (blue.udo.OpcodeList)4 BlueData (blue.BlueData)3 CompileData (blue.CompileData)3 GlobalOrcSco (blue.GlobalOrcSco)3 Tables (blue.Tables)3 Channel (blue.mixer.Channel)3 ChannelList (blue.mixer.ChannelList)3 GenericInstrument (blue.orchestra.GenericInstrument)3 NoteList (blue.soundObject.NoteList)3 ParameterNameManager (blue.automation.ParameterNameManager)2 LinePoint (blue.components.lines.LinePoint)2 TempoMapper (blue.noteProcessor.TempoMapper)2 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)2 BSBGraphicInterface (blue.orchestra.blueSynthBuilder.BSBGraphicInterface)2 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)2 BSBSubChannelDropdown (blue.orchestra.blueSynthBuilder.BSBSubChannelDropdown)2 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)2