Search in sources :

Example 16 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class BSBVSliderBank method setObjectName.

// OVERRIDE to handle Parameter name changes and multiple parameters
@Override
public void setObjectName(String objectName) {
    if (objectName == null || objectName.equals(getObjectName())) {
        return;
    }
    if (unm != null) {
        if (!objectName.isEmpty()) {
            Object[] vals = new Object[2];
            vals[0] = objectName;
            for (int i = 0; i < sliders.size(); i++) {
                vals[1] = new Integer(i);
                String objName = KEY_FMT.format(vals);
                if (!unm.isUnique(objName)) {
                    return;
                }
            }
        }
    }
    String oldName = this.getObjectName();
    boolean doInitialize = false;
    if (parameters != null && automationAllowed) {
        Object[] vals = new Object[2];
        vals[0] = oldName;
        Object[] vals2 = new Object[2];
        vals2[0] = objectName;
        if (!objectName.isEmpty()) {
            for (int i = 0; i < sliders.size(); i++) {
                vals[1] = new Integer(i);
                String oldKey = KEY_FMT.format(vals);
                parameters.removeParameter(oldKey);
            }
        } else {
            boolean missingParameters = false;
            for (int i = 0; i < sliders.size(); i++) {
                vals[1] = new Integer(i);
                vals2[1] = new Integer(i);
                String oldKey = KEY_FMT.format(vals);
                String newKey = KEY_FMT.format(vals2);
                Parameter param = parameters.getParameter(oldKey);
                if (param == null) {
                    missingParameters = true;
                    break;
                } else {
                    param.setName(newKey);
                }
            }
            if (missingParameters) {
                for (int i = 0; i < sliders.size(); i++) {
                    vals[1] = new Integer(i);
                    String oldKey = KEY_FMT.format(vals);
                    parameters.removeParameter(oldKey);
                }
                doInitialize = true;
            }
        }
    }
    this.objectNameProperty().set(objectName);
    if (doInitialize) {
        initializeParameters();
    }
}
Also used : Parameter(blue.automation.Parameter)

Example 17 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class BSBVSliderBank method setNumberOfSliders.

public void setNumberOfSliders(int numSliders) {
    if (numSliders > 0 && numSliders != sliders.size()) {
        int diff = numSliders - sliders.size();
        String objectName = getObjectName();
        Object[] vals = new Object[2];
        vals[0] = objectName;
        if (diff > 0) {
            if (!willBeUnique(numSliders)) {
                return;
            }
            BSBVSlider lastSlider = (BSBVSlider) sliders.get(sliders.size() - 1);
            for (int i = 0; i < diff; i++) {
                BSBVSlider copy = new BSBVSlider(lastSlider);
                sliders.add(copy);
                if (parameters != null && objectName != null && objectName.trim().length() > 0) {
                    vals[1] = new Integer(sliders.size() - 1);
                    String key = KEY_FMT.format(vals);
                    Parameter param = new Parameter();
                    param.setName(key);
                    // order of setting these is important
                    if (getMinimum() > param.getMax()) {
                        param.setMax(getMaximum(), true);
                        param.setMin(getMinimum(), true);
                    } else {
                        param.setMin(getMinimum(), true);
                        param.setMax(getMaximum(), true);
                    }
                    param.setResolution(getResolution());
                    param.setValue(copy.getValue());
                    param.addParameterListener(this);
                    parameters.add(param);
                }
            }
        } else {
            for (int i = 0; i < -diff; i++) {
                BSBVSlider slider = (BSBVSlider) sliders.get(sliders.size() - 1);
                sliders.remove(slider);
                if (parameters != null && objectName != null && objectName.trim().length() > 0) {
                    vals[1] = new Integer(sliders.size());
                    String key = KEY_FMT.format(vals);
                    parameters.removeParameter(key);
                }
            }
        }
    }
    fireBSBObjectChanged();
}
Also used : Parameter(blue.automation.Parameter)

Example 18 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class BSBVSliderBank method getParameters.

private List<Parameter> getParameters() {
    List<Parameter> params = new ArrayList<>();
    if (parameters != null) {
        Object[] vals = new Object[2];
        vals[0] = getObjectName();
        for (int i = 0; i < sliders.size(); i++) {
            vals[1] = new Integer(i);
            String key = KEY_FMT.format(vals);
            Parameter param = parameters.getParameter(key);
            if (param != null) {
                params.add(param);
            }
        }
    }
    return params;
}
Also used : ArrayList(java.util.ArrayList) Parameter(blue.automation.Parameter)

Example 19 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class CSDRender method handleParameters.

private void handleParameters(ArrayList parameters, ArrayList<StringChannel> stringChannels, GlobalOrcSco globalOrcSco, NoteList notes, Arrangement arrangement, double startTime, double endTime, boolean isRealTime, boolean _usingAPI) {
    Object[] varNum = new Object[1];
    StrBuilder initStatements = new StrBuilder();
    StrBuilder paramScore = new StrBuilder();
    boolean useAPI = isRealTime && _usingAPI;
    for (StringChannel strChannel : stringChannels) {
        String varName = strChannel.getChannelName();
        initStatements.append(varName);
        initStatements.append(" = ");
        initStatements.append("\"").append(strChannel.getValue()).append("\"\n");
        if (useAPI) {
            initStatements.append(varName).append(" chnexport \"");
            initStatements.append(varName).append("\", 3\n");
        }
    }
    for (int i = 0; i < parameters.size(); i++) {
        Parameter param = (Parameter) parameters.get(i);
        varNum[0] = new Integer(i);
        String varName = param.getCompilationVarName();
        // param.setCompilationVarName(varName);
        double initialVal;
        if (param.isAutomationEnabled()) {
            initialVal = param.getLine().getValue(startTime);
        } else {
            initialVal = param.getFixedValue();
        }
        // init statements
        initStatements.append(varName);
        initStatements.append(" init ");
        initStatements.append(NumberUtilities.formatDouble(initialVal));
        initStatements.append("\n");
        if (useAPI) {
            initStatements.append(varName).append(" chnexport \"");
            initStatements.append(varName).append("\", 3\n");
        } else if (param.isAutomationEnabled()) {
            // gk instrument
            GenericInstrument instr = getParameterInstrument(param);
            int instrId = arrangement.addInstrumentAtEnd(instr);
            // score for values
            appendParameterScore(param, instrId, paramScore, startTime, endTime);
        }
    }
    globalOrcSco.appendGlobalOrc(initStatements.toString());
    try {
        notes.addAll(ScoreUtilities.getNotes(paramScore.toString()));
    } catch (NoteParseException ex) {
        ex.printStackTrace();
    }
// globalOrcSco.appendGlobalSco(paramScore.toString());
}
Also used : NoteParseException(blue.soundObject.NoteParseException) StringChannel(blue.orchestra.blueSynthBuilder.StringChannel) Parameter(blue.automation.Parameter) GenericInstrument(blue.orchestra.GenericInstrument) StrBuilder(org.apache.commons.lang3.text.StrBuilder) LinePoint(blue.components.lines.LinePoint)

Example 20 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class ParameterHelper method getActiveParameters.

public static List<Parameter> getActiveParameters(Arrangement arr, Mixer mixer) {
    List<Parameter> params = new ArrayList<>();
    for (int i = 0; i < arr.size(); i++) {
        InstrumentAssignment ia = arr.getInstrumentAssignment(i);
        if (ia.enabled) {
            Instrument instr = ia.instr;
            if (instr instanceof Automatable) {
                Automatable auto = (Automatable) instr;
                ParameterList list = auto.getParameterList();
                addActiveParametersFromList(params, list);
            }
        }
    }
    if (mixer != null && mixer.isEnabled()) {
        List<Channel> channels = mixer.getAllSourceChannels();
        for (Channel channel : channels) {
            appendParametersFromChannel(params, channel);
        }
        ChannelList subChannels = mixer.getSubChannels();
        for (Channel subChannel : subChannels) {
            appendParametersFromChannel(params, subChannel);
        }
        appendParametersFromChannel(params, mixer.getMaster());
    }
    return params;
}
Also used : Channel(blue.mixer.Channel) ArrayList(java.util.ArrayList) Instrument(blue.orchestra.Instrument) Parameter(blue.automation.Parameter) InstrumentAssignment(blue.InstrumentAssignment) ParameterList(blue.automation.ParameterList) ChannelList(blue.mixer.ChannelList) Automatable(blue.automation.Automatable)

Aggregations

Parameter (blue.automation.Parameter)47 LinePoint (blue.components.lines.LinePoint)6 ParameterList (blue.automation.ParameterList)5 BigDecimal (java.math.BigDecimal)5 ArrayList (java.util.ArrayList)5 Automatable (blue.automation.Automatable)4 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)4 Instrument (blue.orchestra.Instrument)3 StrBuilder (org.apache.commons.lang3.text.StrBuilder)3 InstrumentAssignment (blue.InstrumentAssignment)2 Channel (blue.mixer.Channel)2 ChannelList (blue.mixer.ChannelList)2 GenericInstrument (blue.orchestra.GenericInstrument)2 NoteParseException (blue.soundObject.NoteParseException)2 Sound (blue.soundObject.Sound)2 Arrangement (blue.Arrangement)1 BlueData (blue.BlueData)1 CompileData (blue.CompileData)1 GlobalOrcSco (blue.GlobalOrcSco)1 SoundLayer (blue.SoundLayer)1