Package javax.sound.sampled

Examples of javax.sound.sampled.Mixer$Info


   */
  public static void listMixersAndExit(boolean bPlayback) {
    out("Available Mixers:");
    Mixer.Info[] aInfos = AudioSystem.getMixerInfo();
    for (int i = 0; i < aInfos.length; i++) {
      Mixer mixer = AudioSystem.getMixer(aInfos[i]);
      Line.Info lineInfo = new Line.Info(bPlayback ? SourceDataLine.class
          : TargetDataLine.class);
      if (mixer.isLineSupported(lineInfo)) {
        out(aInfos[i].getName());
      }
    }
    if (aInfos.length == 0) {
      out("[No mixers available]");
View Full Code Here


        if (mixerInfo == null) {
          out("AudioCommon.getTargetDataLine(): mixer not found: "
              + strMixerName);
          return null;
        }
        Mixer mixer = AudioSystem.getMixer(mixerInfo);
        targetDataLine = (TargetDataLine) mixer.getLine(info);
      } else {
        if (DEBUG) {
          out("AudioCommon.getTargetDataLine(): using default mixer");
        }
        targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
View Full Code Here

import javax.sound.sampled.TargetDataLine;

public class SoundTestAusgabeAllerGeraete {
  public static void main(String[] args) {
    System.out.println("Available:");
    Mixer mixer = null;
    Mixer.Info[] mixerinfos = AudioSystem.getMixerInfo();
    for(int i=0; i<mixerinfos.length; i++)
    {
      mixer = AudioSystem.getMixer(mixerinfos[i]);
      System.out.println("\n " + mixerinfos[i].getName() + " (Name: " + mixerinfos[i].getName() +
        " / Vendor: " + mixerinfos[i].getVendor() + " / Version: " + mixerinfos[i].getVersion() + ")");
     
      Line.Info[] sLineInfos = mixer.getSourceLineInfo();
      System.out.println("  Sources (" + sLineInfos.length + "):");
      for(int k=0; k<sLineInfos.length; k++)
      {
        try
        {
          SourceDataLine sLine = (SourceDataLine)mixer.getLine(sLineInfos[k]);
          System.out.println("   Line: " + sLine.getLineInfo() + "\t(Name: " + sLine + ")");
        }
        catch (LineUnavailableException e)
        {
          e.printStackTrace();
        }
        catch(ClassCastException e)
        {
          try
          {
            Clip sClip = (Clip)mixer.getLine(sLineInfos[k]);
            System.out.println("   Clip: " + sClip.getLineInfo() + "\t(Name: " + sClip + ")");
          }
          catch (LineUnavailableException e1)
          {
            e1.printStackTrace();
          }
          catch(ClassCastException e1)
          {
            try
            {
              Port sPort = (Port)mixer.getLine(sLineInfos[k]);
              System.out.println("   Port: " + sPort.getLineInfo() + "\t(Name: " + sPort + ")");
            }
            catch (LineUnavailableException e2)
            {
              e2.printStackTrace();
            }
          }
        }
       
      }
     
      Line.Info[] tLineInfos = mixer.getTargetLineInfo();
      System.out.println("  Targets (" + tLineInfos.length + "):");
      for(int k=0; k<tLineInfos.length; k++)
      {
        try
        {
          TargetDataLine tLine = (TargetDataLine)mixer.getLine(tLineInfos[k]);
          System.out.println("   Line: " + tLine.getLineInfo() + "\t(Name: " + tLine + ")");
        }
        catch (LineUnavailableException e)
        {
          e.printStackTrace();
        }
        catch(ArrayIndexOutOfBoundsException e)
        {
         
        }
        catch(ClassCastException e)
        {
          try
          {
            Clip tClip = (Clip)mixer.getLine(tLineInfos[k]);
            System.out.println("   Clip: " + tClip.getLineInfo() + "\t(Name: " + tClip + ")");
          }
          catch (LineUnavailableException e1)
          {
            e1.printStackTrace();
          }
          catch(ClassCastException e1)
          {
            try
            {
              Port tPort = (Port)mixer.getLine(tLineInfos[k]);
              System.out.println("   Port: " + tPort.getLineInfo() + "\t(Name: " + tPort + ")");
            }
            catch (LineUnavailableException e2)
            {
              e2.printStackTrace();
View Full Code Here

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

      mixer = AudioSystem.getMixer(info);
      final int maxLines = mixer.getMaxLines(Port.Info.MICROPHONE);
      if (maxLines > 0) {
        System.out.println(info);
        lineIn = (Port) mixer.getLine(Port.Info.MICROPHONE);
        lineIn.open();
        Control[] controls = lineIn.getControls();
        for (int j = 0; j < controls.length; j++) {
          Control control = controls[j];
          System.out.println(control);
View Full Code Here

    public static void main(String[] args) {
        // loop through all mixers, and all source and target lines within each mixer.
        Mixer.Info[] mis = AudioSystem.getMixerInfo();
        for (Mixer.Info mi : mis) {
            Mixer mixer = AudioSystem.getMixer(mi);
            // e.g. com.sun.media.sound.DirectAudioDevice
            System.out.println("mixer: " + mixer.getClass().getName());
            Line.Info[] lis = mixer.getSourceLineInfo();
            for (Line.Info li : lis) {
                System.out.println("    source line: " + li.toString());

                showFormats(li);
            }
            lis = mixer.getTargetLineInfo();
            for (Line.Info li : lis) {
                System.out.println("    target line: " + li.toString());
                showFormats(li);
            }
            Control[] cs = mixer.getControls();
            for (Control c : cs) {
                System.out.println("    control: " + c.toString());
            }
        }
    }
View Full Code Here

                        SoftMixingMixerProvider.lockthread = Thread
                                .currentThread();
                    }

                    try {
                        Mixer defaultmixer = AudioSystem.getMixer(null);
                        if (defaultmixer != null)
                        {
                            // Search for suitable line
                           
                            DataLine.Info idealinfo = null;
                            AudioFormat idealformat = null;
                           
                            Line.Info[] lineinfos = defaultmixer.getSourceLineInfo();
                            idealFound:
                            for (int i = 0; i < lineinfos.length; i++) {
                                if(lineinfos[i].getLineClass() == SourceDataLine.class)
                                {
                                    DataLine.Info info = (DataLine.Info)lineinfos[i];
                                    AudioFormat[] formats = info.getFormats();
                                    for (int j = 0; j < formats.length; j++) {
                                        AudioFormat format = formats[j];
                                        if(format.getChannels() == 2 ||
                                                format.getChannels() == AudioSystem.NOT_SPECIFIED)
                                        if(format.getEncoding().equals(Encoding.PCM_SIGNED) ||
                                                format.getEncoding().equals(Encoding.PCM_UNSIGNED))
                                        if(format.getSampleRate() == AudioSystem.NOT_SPECIFIED ||
                                                format.getSampleRate() == 48000.0)
                                        if(format.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED ||
                                                format.getSampleSizeInBits() == 16)
                                        {
                                            idealinfo = info;
                                            int ideal_channels = format.getChannels();
                                            boolean ideal_signed = format.getEncoding().equals(Encoding.PCM_SIGNED);
                                            float ideal_rate = format.getSampleRate();
                                            boolean ideal_endian = format.isBigEndian();                                           
                                            int ideal_bits = format.getSampleSizeInBits();                                           
                                            if(ideal_bits == AudioSystem.NOT_SPECIFIED) ideal_bits = 16;
                                            if(ideal_channels == AudioSystem.NOT_SPECIFIED) ideal_channels = 2;
                                            if(ideal_rate == AudioSystem.NOT_SPECIFIED) ideal_rate = 48000;
                                            idealformat = new AudioFormat(ideal_rate, ideal_bits,
                                                    ideal_channels, ideal_signed, ideal_endian);
                                            break idealFound;
                                        }
                                    }
                                }                                   
                            }
                           
                            if(idealformat != null)
                            {
                                format = idealformat;
                                line = (SourceDataLine) defaultmixer.getLine(idealinfo);
                            }
                        }
                       
                        if(line == null)
                            line = AudioSystem.getSourceDataLine(format);
View Full Code Here

    public Mixer getMixer(Mixer.Info info) {
        // if the default device is asked, we provide the mixer
        // with SourceDataLine's
        if (info == null) {
            for (int i = 0; i < infos.length; i++) {
                Mixer mixer = getDevice(infos[i]);
                if (mixer.getSourceLineInfo().length > 0) {
                    return mixer;
                }
            }
        }
        // otherwise get the first mixer that matches
View Full Code Here

        // get infos about all mixers in the system
        Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        // ask how many lines there are, and plot vendor for each on with at least 2 lines
        for (Mixer.Info mixerInfo : mixers) {
            Mixer mixer = AudioSystem.getMixer(mixerInfo);
            // how many lines of the type we need are available
            int maxLines = mixer.getMaxLines(lineInfo);
            // at least two or not specified, print info
            if (maxLines == AudioSystem.NOT_SPECIFIED || maxLines >= 2) {
                System.out.println("Description: " + mixerInfo.getDescription() + " Vendor: " + mixerInfo.getVendor() + " Name: " + mixerInfo.getName());
                try (SourceDataLine line = (SourceDataLine) mixer.getLine(lineInfo)) {
                    line.open();
                    for (Control control : line.getControls()) {
                        System.out.println("Line has control: " + control);
                    }
                }
View Full Code Here

        availableMixers.clear();
        // get infos about mixers
        Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        // ask how many lines there are, and plot vendor for each on with at least 2 lines
        for (Mixer.Info mixerInfo : mixers) {
            Mixer mixer = AudioSystem.getMixer(mixerInfo);
            int maxLines = mixer.getMaxLines(TargetLineInfo);
            if (maxLines == AudioSystem.NOT_SPECIFIED || maxLines >= NumberOfLines) {
                availableMixers.add(mixer);
            }
        }
View Full Code Here

  private Mixer findMixer(String mixerClassName) {
    if (mixerClassName == null) {
      return null;
    }
    for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
      Mixer m = AudioSystem.getMixer(mi);

      if (m.getClass().getSimpleName().equals(mixerClassName)) {
        return m;
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of javax.sound.sampled.Mixer$Info

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.