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();
}
}
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();
}
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;
}
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());
}
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;
}
Aggregations