예제 #1
0
 private Line.Info[] getPortInfo(Mixer mixer) {
   Line.Info[] infos;
   List<Line.Info> portInfoList = new ArrayList<>();
   infos = mixer.getSourceLineInfo();
   for (Line.Info info : infos) {
     if (info instanceof Port.Info || info instanceof DataLine.Info) {
       portInfoList.add(info);
     }
   }
   infos = mixer.getTargetLineInfo();
   for (Line.Info info1 : infos) {
     if (info1 instanceof Port.Info || info1 instanceof DataLine.Info) {
       portInfoList.add(info1);
     }
   }
   return portInfoList.toArray(EMPTY_PORT_INFO_ARRAY);
 }
예제 #2
0
 private boolean arePortsSupported(Mixer mixer) {
   Line.Info[] infos;
   infos = mixer.getSourceLineInfo();
   for (Line.Info info : infos) {
     if (info instanceof Port.Info) {
       return true;
     } else if (info instanceof DataLine.Info) {
       return true;
     }
   }
   infos = mixer.getTargetLineInfo();
   for (Line.Info info : infos) {
     if (info instanceof Port.Info) {
       return true;
     } else if (info instanceof DataLine.Info) {
       return true;
     }
   }
   return false;
 }
  private boolean setupSpeaker(String device) throws LineUnavailableException {

    Mixer.Info[] aInfos = AudioSystem.getMixerInfo();

    for (int i = 0; i < aInfos.length; i++) {
      Mixer.Info mixerInfo = aInfos[i];

      if (GetDataLines.equals(device, mixerInfo) == false) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
          Logger.println("Skipping:  " + mixerInfo.getName() + "," + mixerInfo.getDescription());
        }

        continue;
      }

      try {
        Mixer mixer = AudioSystem.getMixer(mixerInfo);

        Line.Info[] infos = mixer.getSourceLineInfo();

        for (int j = 0; j < infos.length; j++) {
          Line line = (Line) mixer.getLine(infos[j]);

          if (line instanceof SourceDataLine) {
            speaker = (SourceDataLine) line;

            if (Logger.logLevel >= Logger.LOG_INFO) {
              Logger.println("Found speaker:  " + j);
            }
            break;
          }
        }
      } catch (Exception e) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
          Logger.println("Exception:  " + e.getMessage());
        }
      }
    }

    return speaker != null;
  }
예제 #4
0
파일: at1.java 프로젝트: BerndDammer/at1
 private static void d1() {
   Mixer.Info[] fmi = AudioSystem.getMixerInfo();
   for (Mixer.Info mi : fmi) {
     Mixer mixer = AudioSystem.getMixer(mi);
     Line.Info[] isl = mixer.getSourceLineInfo();
     Line.Info[] itl = mixer.getTargetLineInfo();
     // if( itl.length > 0)
     {
       error.log("--------------------------------------------------------------");
       error.log("Src Count " + isl.length + " Target size " + itl.length);
       error.log(mi.toString());
       error.log("Name " + mi.getName());
       error.log("Version " + mi.getVersion());
       error.log("Vendor " + mi.getVendor());
       error.log("Description " + mi.getDescription());
       error.log("~~~");
       dumpLines(isl, "  >> SourceLine  : ");
       dumpLines(itl, "  >> TargetLine  : ");
     }
   }
 }
  private void mixerComboBoxActionPerformed() {
    Mixer mixer = AudioSystem.getMixer((Mixer.Info) mixerComboBox.getSelectedItem());

    Line.Info lineInfo = mixer.getSourceLineInfo(new Line.Info(Clip.class))[0];

    boolean volumeSupported;
    boolean panSupported;

    try {
      Line line = mixer.getLine(lineInfo);

      volumeSupported = line.isControlSupported(FloatControl.Type.MASTER_GAIN);
      panSupported = line.isControlSupported(FloatControl.Type.PAN);
    } catch (LineUnavailableException e) {
      volumeSupported = false;
      panSupported = false;
    }

    enableMixerVolumeCheckBox.setEnabled(volumeSupported);
    enableMixerPanCheckBox.setEnabled(panSupported);
  }
  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
    // the requested info object
    for (int i = 0; i < infos.length; i++) {
      if (infos[i].equals(info)) {
        return getDevice(infos[i]);
      }
    }

    throw new IllegalArgumentException(
        "Mixer " + info.toString() + " not supported by this provider.");
  }
예제 #7
0
  private static Mixer.Info[] getAvailableMixers(boolean isTarget) {
    ArrayList<Mixer.Info> mixers =
        new ArrayList<Mixer.Info>(Arrays.asList((Mixer.Info[]) AudioSystem.getMixerInfo()));
    for (Iterator<Mixer.Info> it = mixers.iterator(); it.hasNext(); ) {
      Mixer.Info minfo = it.next();
      Mixer mixer = AudioSystem.getMixer(minfo);

      Line.Info[] linfo = (isTarget) ? mixer.getTargetLineInfo() : mixer.getSourceLineInfo();
      boolean hasDataLine = false;
      for (int j = 0; j < linfo.length; j++) {
        if (linfo[j] instanceof DataLine.Info) {
          hasDataLine = true;
          break;
        }
      }
      if (!hasDataLine) {
        it.remove();
      }
    }

    return mixers.toArray(new Mixer.Info[mixers.size()]);
  }
예제 #8
0
  public String toString() {
    Mixer.Info info = mixer.getMixerInfo();

    String s = "\nMixer [" + id + "]";
    s += "\n\t Name: " + info.getName();
    s += "\n\t Desc: " + info.getDescription();
    s += "\n\t Ven : " + info.getVendor();
    s += "\n\t Ver : " + info.getVersion();
    s += "\n\t Str : " + info.toString();

    Line.Info[] infos = mixer.getSourceLineInfo();
    s += "\n\nSourceLine count : " + infos.length;
    for (int i = 0; i < infos.length; i++) {
      if (infos[i] instanceof DataLine.Info) {
        s += "\n\t\tData Line Source [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else if (infos[i] instanceof Port.Info) {
        s += "\n\t\tPort Source [" + i + "]";
        s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName();
        s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource();
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else /*if(infos[i]!=null)*/ {
        s += "\n\t\tSource [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      }
    }
    s += "\n\nOUTPUT\n";
    for (int i = 0; i < formats.length; i++) {
      try {
        SourceDataLine out = getOutputLine(formats[i]);
        out.close();
        s += "\n" + formats[i].toString();
      } catch (Exception e) {
        //        s+="\n"+e.getMessage();
      }
    }

    infos = mixer.getTargetLineInfo();
    s += "\n\nTargetLine count : " + infos.length;
    for (int i = 0; i < infos.length; i++) {
      if (infos[i] instanceof DataLine.Info) {
        s += "\n\t\tData Line Target [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else if (infos[i] instanceof Port.Info) {
        s += "\n\t\tPort Target [" + i + "]";
        s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName();
        s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource();
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else /*if(infos[i]!=null)*/ {
        s += "\n\t\tTarget [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      }
    }

    s += "\n\nINPUT\n";
    for (int i = 0; i < formats.length; i++) {
      try {
        TargetDataLine out = getInputLine(formats[i]);
        out.close();
        s += "\n" + formats[i].toString();
      } catch (Exception e) {
        //        s+="\n"+e.getMessage();
      }
    }

    return s;
  }