Search in sources :

Example 6 with FloatControl

use of javax.sound.sampled.FloatControl in project ChessProject by DylanSantora.

the class Sound method setVolume.

public void setVolume(float f) {
    FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    volume.setValue(f);
}
Also used : FloatControl(javax.sound.sampled.FloatControl)

Example 7 with FloatControl

use of javax.sound.sampled.FloatControl in project Minim by ddf.

the class Controller method getValue.

private float getValue(FloatControl.Type type) {
    float v = 0;
    if (hasControl(type)) {
        FloatControl c = (FloatControl) getControl(type);
        v = c.getValue();
    } else {
        Minim.error(type.toString() + " is not supported.");
    }
    return v;
}
Also used : FloatControl(javax.sound.sampled.FloatControl)

Example 8 with FloatControl

use of javax.sound.sampled.FloatControl in project Minim by ddf.

the class Controller method setValue.

private void setValue(FloatControl.Type type, float v) {
    if (hasControl(type)) {
        FloatControl c = (FloatControl) getControl(type);
        if (v > c.getMaximum())
            v = c.getMaximum();
        else if (v < c.getMinimum())
            v = c.getMinimum();
        c.setValue(v);
    } else {
        Minim.error(type.toString() + " is not supported.");
    }
}
Also used : FloatControl(javax.sound.sampled.FloatControl)

Example 9 with FloatControl

use of javax.sound.sampled.FloatControl in project Minim by ddf.

the class Controller method printControls.

/** @invisible
   * 
   * Prints the available controls and their ranges to the console. Not all
   * Controllers have all of the controls available on them so this is a way to find
   * out what is available.
   * 
   */
public void printControls() {
    if (controls.length > 0) {
        System.out.println("Available controls are:");
        for (int i = 0; i < controls.length; i++) {
            Control.Type type = controls[i].getType();
            System.out.print("  " + type.toString());
            if (type == VOLUME || type == GAIN || type == BALANCE || type == PAN) {
                FloatControl fc = (FloatControl) controls[i];
                String shiftSupported = "does";
                if (fc.getUpdatePeriod() == -1) {
                    shiftSupported = "doesn't";
                }
                System.out.println(", which has a range of " + fc.getMaximum() + " to " + fc.getMinimum() + " and " + shiftSupported + " support shifting.");
            } else {
                System.out.println("");
            }
        }
    } else {
        System.out.println("There are no controls available.");
    }
}
Also used : FloatControl(javax.sound.sampled.FloatControl) BooleanControl(javax.sound.sampled.BooleanControl) Control(javax.sound.sampled.Control) FloatControl(javax.sound.sampled.FloatControl)

Aggregations

FloatControl (javax.sound.sampled.FloatControl)9 Closure (org.apache.commons.collections.Closure)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 BooleanControl (javax.sound.sampled.BooleanControl)1 Control (javax.sound.sampled.Control)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 Mixer (javax.sound.sampled.Mixer)1 Port (javax.sound.sampled.Port)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1