Examples of FloatControl


Examples of javax.sound.sampled.FloatControl

                            {
                                port.open();
                            }
                            if (port.isControlSupported(FloatControl.Type.VOLUME))
                            {
                                FloatControl volumeControl = (FloatControl) port.getControl(FloatControl.Type.VOLUME);
                                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);
                            }

                        } finally
                        {
                            if (openPortNeeded && port.isOpen())
View Full Code Here

Examples of javax.sound.sampled.FloatControl

                        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;
                                    }
                                }

View Full Code Here

Examples of javax.sound.sampled.FloatControl

                            Line line;
                            try
                            {
                                line = m.getLine(li);
                                Control[] c = line.getControls();
                                FloatControl volume= (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);                                
                                float max = volume.getMaximum();
                                float min = volume.getMinimum();
                                float dist = max-min;
                               
                                float v = dist /100 *vol;

                                volume.setValue(min+v);
                            }
                            catch (Throwable ex)
                            {
                                Logger.getLogger(Audio.class.getName()).log(Level.SEVERE, null, ex);
                            }
View Full Code Here

Examples of javax.sound.sampled.FloatControl

            auline = null;
            return;
        }

        if (auline.isControlSupported(FloatControl.Type.PAN)) {
            FloatControl pan = (FloatControl) auline
                    .getControl(FloatControl.Type.PAN);
            if (curPosition == Position.RIGHT)
                pan.setValue(1.0f);
            else if (curPosition == Position.LEFT)
                pan.setValue(-1.0f);
        }

        auline.start();
        int nBytesRead = 0;
        byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
View Full Code Here

Examples of javax.sound.sampled.FloatControl

            DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
            SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
            line.open(audioFormat);
            line.start();
FloatControl gainControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
double gain = .2d; // number between 0 and 1 (loudest)
float dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0);
gainControl.setValue(dB);
            byte[] buf = new byte[1024];
            while (iss[0].available() > 0) {
                if (channels == 1) {
                    int l = iss[0].read(buf, 0, 1024);
//Debug.dump(buf, 64);
View Full Code Here

Examples of javax.sound.sampled.FloatControl

        SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
        line.open(format);
        line.start();
        byte[] buf = new byte[1024];
        int l = 0;
FloatControl gainControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
double gain = .2d; // number between 0 and 1 (loudest)
float dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0);
gainControl.setValue(dB);

        while (is.available() > 0) {
            l = is.read(buf, 0, 1024);
            line.write(buf, 0, l);
if (os != null) {
View Full Code Here

Examples of javax.sound.sampled.FloatControl

        SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
        line.open(format);
        line.start();
        byte[] buf = new byte[1024];
        int l = 0;
FloatControl gainControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN);
double gain = .2d; // number between 0 and 1 (loudest)
float dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0);
gainControl.setValue(dB);

        while (is.available() > 0) {
            l = is.read(buf, 0, 1024);
            line.write(buf, 0, l);
if (os != null) {
View Full Code Here

Examples of javax.sound.sampled.FloatControl

import javax.sound.sampled.Mixer.Info;

public class SoundMicroTest4 {
  public static void main(String[] args) throws LineUnavailableException {
    Port lineIn = null;
    FloatControl volCtrl = null;
    Mixer mixer = null;

    Mixer.Info[] mixerInfoPool = AudioSystem.getMixerInfo();
    for (int i = 0; i < mixerInfoPool.length; i++) {
      Info info = mixerInfoPool[i];
View Full Code Here

Examples of javax.sound.sampled.FloatControl

            e.printStackTrace();
            return;
        }
        if (auline.isControlSupported(FloatControl.Type.PAN)) {
            FloatControl pan = (FloatControl) auline
                    .getControl(FloatControl.Type.PAN);
            if (curPosition == Position.RIGHT)
                pan.setValue(1.0f);
            else if (curPosition == Position.LEFT)
                pan.setValue(-1.0f);
        }
        auline.start();
        int nBytesRead = 0;
        byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
View Full Code Here

Examples of javax.sound.sampled.FloatControl

    if (c == null) {
      return;
    }

    if (properties.getOptionsSoundEnableMixerPan() && c.isControlSupported(FloatControl.Type.PAN)) {
      FloatControl panCtrl = (FloatControl) c.getControl(FloatControl.Type.PAN);

      panCtrl.setValue(pan);
    }
    if (properties.getOptionsSoundEnableMixerVolume() && c.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
      FloatControl volCtrl = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);

      float min = volCtrl.getMinimum() / 4;

      if (volume != 1) {
        volCtrl.setValue(min * (1 - volume));
      }
    }
    c.loop(loop);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.