Control[] aControls = port.getControls();
for (int t = 0; t < aControls.length; t++)
{
if (aControls[t] instanceof FloatControl)
{
FloatControl control = (FloatControl) aControls[t];
Control.Type type = control.getType();
String strControlName = type.toString();
if (!isVolumne(control)) continue;
//System.out.println("Control direct: " + strControlName);
//
FloatControl volumeControl = (FloatControl) control;
float min = volumeControl.getMinimum();
float max = volumeControl.getMaximum();
float current = volumeControl.getValue();
double percent = 100.0 * (current - min) / (max - min);
// System.out.println("Current Volume is " + percent + "%.");
volumeSet = true;
// setting to 50%
float v = (max - min) / 2.0f + min;
v = (((max - min)/100)*vol) +min;
volumeControl.setValue(v);
}
if (aControls[t] instanceof CompoundControl)
{
CompoundControl control = (CompoundControl) aControls[t];
String strControlName = control.getType().toString();
//System.out.println("Control compound: " + strControlName);
Control[] subControls = control.getMemberControls();
for (int s = 0; s < subControls.length; s++)
{
Control con = subControls[s];
if (con instanceof FloatControl)
{
FloatControl subCon = (FloatControl)con;
String strControlSubName = subCon.getType().toString();
if (!isVolumne(subCon)) continue;
//System.out.println("Control sub: " + strControlSubName);
//
FloatControl volumeControl = (FloatControl) subCon;
float min = volumeControl.getMinimum();
float max = volumeControl.getMaximum();
float current = volumeControl.getValue();
double percent = 100.0 * (current - min) / (max - min);
// System.out.println("Current Volume is " + percent + "%.");
// setting to 50%
float v = (max - min) / 2.0f + min;
v = (((max - min)/100)*vol) +min;
volumeControl.setValue(v);
volumeSet = true;
}
}