use of blue.automation.Parameter in project blue by kunstmusik.
the class BSBHSliderBank method initializeParameters.
@Override
public void initializeParameters() {
if (parameters == null) {
return;
}
if (!automationAllowed) {
String objectName = getObjectName();
if (parameters != null) {
if (objectName != null && objectName.length() != 0) {
Object[] vals = new Object[2];
vals[0] = objectName;
vals[1] = new Integer(0);
Parameter param = parameters.getParameter(KEY_FMT.format(vals));
if (param != null && param.isAutomationEnabled()) {
automationAllowed = true;
} else {
for (int i = 0; i < sliders.size(); i++) {
vals[1] = new Integer(i);
String oldKey = KEY_FMT.format(vals);
parameters.removeParameter(oldKey);
}
return;
}
}
}
}
if (getObjectName() == null || getObjectName().trim().length() == 0) {
return;
}
Object[] vals = new Object[2];
vals[0] = getObjectName();
boolean missingParameters = false;
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) {
missingParameters = true;
break;
}
if (!param.isAutomationEnabled()) {
BSBHSlider slider = (BSBHSlider) sliders.get(i);
param.setValue(slider.getValue());
}
param.addParameterListener(this);
}
if (!missingParameters) {
return;
}
for (int i = 0; i < sliders.size(); i++) {
BSBHSlider slider = (BSBHSlider) sliders.get(i);
vals[1] = new Integer(i);
String key = KEY_FMT.format(vals);
// clear for safety
parameters.removeParameter(key);
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(slider.getValue());
param.addParameterListener(this);
parameters.add(param);
}
}
use of blue.automation.Parameter in project blue by kunstmusik.
the class BSBHSliderBank method setupForCompilation.
/*
* (non-Javadoc)
*
* @see blue.orchestra.blueSynthBuilder.BSBObject#setupForCompilation(blue.orchestra.blueSynthBuilder.BSBCompilationUnit)
*/
@Override
public void setupForCompilation(BSBCompilationUnit compilationUnit) {
Object[] vals = new Object[2];
vals[0] = getObjectName();
for (int i = 0; i < sliders.size(); i++) {
BSBHSlider slider = sliders.get(i);
vals[1] = new Integer(i);
String key = KEY_FMT.format(vals);
if (parameters != null) {
Parameter param = parameters.getParameter(key);
if (param != null && param.getCompilationVarName() != null) {
compilationUnit.addReplacementValue(key, param.getCompilationVarName());
continue;
}
}
compilationUnit.addReplacementValue(key, NumberUtilities.formatDouble(slider.getValue()));
}
}
use of blue.automation.Parameter in project blue by kunstmusik.
the class BSBCheckBox method lineDataChanged.
@Override
public void lineDataChanged(Parameter param) {
Parameter parameter = parameters.getParameter(this.getObjectName());
if (parameter != null) {
double time = ParameterTimeManagerFactory.getInstance().getTime();
long val = Math.round(parameter.getLine().getValue(time));
boolean newSelected = (val > 0);
if (newSelected != isSelected()) {
updateSelected(newSelected);
}
}
}
use of blue.automation.Parameter in project blue by kunstmusik.
the class BSBHSlider method lineDataChanged.
@Override
public void lineDataChanged(Parameter param) {
Parameter parameter = parameters.getParameter(this.getObjectName());
if (parameter != null) {
double time = ParameterTimeManagerFactory.getInstance().getTime();
double val = parameter.getLine().getValue(time);
setValue(val);
}
}
use of blue.automation.Parameter in project blue by kunstmusik.
the class Sound method setBlueSynthBuilder.
public void setBlueSynthBuilder(BlueSynthBuilder bsbObj) {
if (this.bsbObj != null) {
ParameterList paramList = bsbObj.getParameterList();
paramList.removeListener(paramListListener);
}
ParameterList paramList = bsbObj.getParameterList();
for (Parameter param : paramList) {
adjustLineType(param);
}
paramList.addListener(paramListListener);
this.bsbObj = bsbObj;
}
Aggregations