Package javax.sound.sampled

Examples of javax.sound.sampled.FloatControl$Type


  public void setVolume(float vol) {
    if (vol > 1)
      vol = 1.0f;
    else if (vol < 0)
      vol = 0.0f;
    FloatControl volume = (FloatControl) clip
        .getControl(FloatControl.Type.VOLUME);
    volume.setValue(vol);
  }
View Full Code Here


    if (outputLine == null) {
      return;
    }
   
    try {
      FloatControl control = (FloatControl) outputLine.getControl(FloatControl.Type.MASTER_GAIN);
      float max = control.getMaximum();
      float min = control.getMinimum(); // negative values all seem to be zero?
       
      if (gain > max)
        gain = max;
      else if (gain < min)
        gain = min;
     
      this.gain = gain;
     
      control.setValue(gain);
    } catch (IllegalArgumentException e) {
      // gain not supported
      e.printStackTrace();
    }
  }
View Full Code Here

    if (outputLine == null) {
      return;
    }
   
    try {
      FloatControl control = (FloatControl) outputLine.getControl(FloatControl.Type.BALANCE);
      control.setValue(balance);
    } catch (IllegalArgumentException e) {
      // balance not supported
    }
  }
View Full Code Here

    else if (vol < 0.0f)
      vol = 0.0f;
   
    float gainDB = (float) (20.0 * Math.log(vol));
   
    FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    volume.setValue(gainDB);
  }
View Full Code Here

    return false;
  }

  @Override
  public void setVolume(int percent) {
    FloatControl volume = (FloatControl) line
        .getControl(FloatControl.Type.MASTER_GAIN);
    float max = volume.getMaximum();
    float min = volume.getMinimum();
    float range = 0;
    if (max < 0) {
      range = Math.abs(min) - Math.abs(max);
    } else {
      if (min >= 0) {
        range = max - min;
      } else {
        range = Math.abs(min) + max;
      }
    }
    float value = percent * range / 100F;
    volume.setValue(min + value);
  }
View Full Code Here

    }
  }

  @Override
  public void setVolume(int percent) {
    FloatControl volume = (FloatControl) clip
        .getControl(FloatControl.Type.MASTER_GAIN);
    float max = volume.getMaximum();
    float min = volume.getMinimum();
    float range = 0;
    if (max < 0) {
      range = Math.abs(min) - Math.abs(max);
    } else {
      if (min >= 0) {
        range = max - min;
      } else {
        range = Math.abs(min) + max;
      }
    }
    float value = percent * range / 100F;
    volume.setValue(min + value);
  }
View Full Code Here

  }

  private static void setMasterVolumeJavaSound(final float volume) {
    runVolumeCommand(new Closure() {
      public void execute(Object input) {
        FloatControl volumeControl = (FloatControl) input;
        volumeControl.setValue(volume);
      }
    });
  }
View Full Code Here

  private static float getMasterVolumeJavaSound() throws IOException {
    final Float[] volumes = new Float[1];
    runVolumeCommand(new Closure() {
      public void execute(Object input) {
        FloatControl volumeControl = (FloatControl) input;
        volumes[0] = volumeControl.getValue();
      }
    });
    if(volumes[0]!=null) {
      return volumes[0];
    } else {
View Full Code Here

        Port port;
        try {
          port = (Port) mixer.getLine(Port.Info.SPEAKER);
          port.open();
          if (port.isControlSupported(FloatControl.Type.VOLUME)) {
            FloatControl volume = (FloatControl) port.getControl(FloatControl.Type.VOLUME);
            closure.execute(volume);
          }
          port.close();
        } catch (LineUnavailableException e) {
          logger.error("Cannot access master volume control", e);
View Full Code Here

            // The line acquires system resources (throws LineAvailableException).
            dataLine.open(audioFormat);

            // Adjust the volume on the output line.
            if (dataLine.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
                FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN);
                volume.setValue(100.0F);
            }

            // Allows the line to move data in and out to a port.
            dataLine.start();
View Full Code Here

TOP

Related Classes of javax.sound.sampled.FloatControl$Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.