当前位置:  开发笔记 > 编程语言 > 正文

Java Sound API在您的计算机上找到哪些输出和记录端口?

如何解决《JavaSoundAPI在您的计算机上找到哪些输出和记录端口?》经验,为你挑选了4个好方法。

我正在使用Java Sound API,如果我想调整记录卷,我需要对操作系统公开给Java的硬件进行建模.事实证明,所呈现的内容有很多种.

因此,我谦虚地要求任何人能够帮助我在他们的计算机上运行以下内容并回发结果,以便我可以了解那里有什么.

提前感谢任何可以提供帮助的人:-)

import javax.sound.sampled.*;
public class SoundAudit {
  public static void main(String[] args) { try {
    System.out.println("OS: "+System.getProperty("os.name")+" "+
      System.getProperty("os.version")+"/"+
      System.getProperty("os.arch")+"\nJava: "+
      System.getProperty("java.version")+" ("+
      System.getProperty("java.vendor")+")\n");
      for (Mixer.Info thisMixerInfo : AudioSystem.getMixerInfo()) {
        System.out.println("Mixer: "+thisMixerInfo.getDescription()+
          " ["+thisMixerInfo.getName()+"]");
        Mixer thisMixer = AudioSystem.getMixer(thisMixerInfo);
        for (Line.Info thisLineInfo:thisMixer.getSourceLineInfo()) {
            if (thisLineInfo.getLineClass().getName().equals(
              "javax.sound.sampled.Port")) {
              Line thisLine = thisMixer.getLine(thisLineInfo);
              thisLine.open();
              System.out.println("  Source Port: "
                +thisLineInfo.toString());
              for (Control thisControl : thisLine.getControls()) {
                System.out.println(AnalyzeControl(thisControl));}
              thisLine.close();}}
        for (Line.Info thisLineInfo:thisMixer.getTargetLineInfo()) {
          if (thisLineInfo.getLineClass().getName().equals(
            "javax.sound.sampled.Port")) {
            Line thisLine = thisMixer.getLine(thisLineInfo);
            thisLine.open();
            System.out.println("  Target Port: "
              +thisLineInfo.toString());
            for (Control thisControl : thisLine.getControls()) {
              System.out.println(AnalyzeControl(thisControl));}
            thisLine.close();}}}
  } catch (Exception e) {e.printStackTrace();}}
  public static String AnalyzeControl(Control thisControl) {
    String type = thisControl.getType().toString();
    if (thisControl instanceof BooleanControl) {
      return "    Control: "+type+" (boolean)"; }
    if (thisControl instanceof CompoundControl) {
      System.out.println("    Control: "+type+
        " (compound - values below)");
      String toReturn = "";
      for (Control children:
        ((CompoundControl)thisControl).getMemberControls()) {
        toReturn+="  "+AnalyzeControl(children)+"\n";}
      return toReturn.substring(0, toReturn.length()-1);}
    if (thisControl instanceof EnumControl) {
      return "    Control:"+type+" (enum: "+thisControl.toString()+")";}
    if (thisControl instanceof FloatControl) {
      return "    Control: "+type+" (float: from "+
        ((FloatControl) thisControl).getMinimum()+" to "+
        ((FloatControl) thisControl).getMaximum()+")";}
    return "    Control: unknown type";}
} 

所有应用程序都打印出关于操作系统的一行,关于JVM的一行,以及关于可能与录制硬件有关的硬件的几行.例如,在我工作的PC上,我得到以下内容:

操作系统:Windows XP 5.1/x86 Java:1.6.0_07(Sun Microsystems Inc.)

Mixer: Direct Audio Device: DirectSound Playback [Primary Sound Driver]
Mixer: Direct Audio Device: DirectSound Playback [SoundMAX HD Audio]
Mixer: Direct Audio Device: DirectSound Capture [Primary Sound Capture Driver]
Mixer: Direct Audio Device: DirectSound Capture [SoundMAX HD Audio]
Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: Port Mixer [Port SoundMAX HD Audio]
  Source Port: MICROPHONE source port
    Control: Microphone (compound - values below)
      Control: Select (boolean)
      Control: Microphone Boost (boolean)
      Control: Front panel microphone (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: LINE_IN source port
    Control: Line In (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0) 

小智.. 6

OS: Mac OS X 10.5.6/i386
Java: 1.5.0_16 (Apple Inc.)

Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: No details available [Built-in Microphone]
Mixer: No details available [Built-in Input]


JMD.. 5

OS: Windows XP 5.1/x86
Java: 1.6.0_12 (Sun Microsystems Inc.)

Mixer: Direct Audio Device: DirectSound Playback [Primary Sound Driver]
Mixer: Direct Audio Device: DirectSound Playback [SoundMAX Digital Audio]
Mixer: Direct Audio Device: DirectSound Capture [Primary Sound Capture Driver]
Mixer: Direct Audio Device: DirectSound Capture [SoundMAX Digital Audio]
Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: Port Mixer [Port SoundMAX Digital Audio]
  Source Port: COMPACT_DISC source port
    Control: CD Player (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: MICROPHONE source port
    Control: Microphone (compound - values below)
      Control: Select (boolean)
      Control: MIC Boost (boolean)
      Control: Mic2 Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Aux source port
    Control: Aux (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: LINE_IN source port
    Control: Line In (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: Phone source port
    Control: Phone (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Mono Out source port
    Control: Mono Out (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Wave Out Mix source port
    Control: Wave Out Mix (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Target Port: SPEAKER target port
    Control: Volume (float: from 0.0 to 1.0)
    Control: Balance (float: from -1.0 to 1.0)
    Control: AC3 SPDIF (boolean)
    Control: PCM SPDIF (boolean)
    Control: Mute (boolean)
    Control: Wave (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: SW Synth (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: BassBoost (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: CD Player (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Microphone (compound - values below)
      Control: Mic2 Select (boolean)
      Control: MIC Boost (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: Aux (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Line In (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Phone (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: Mono Out (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)

注意:从http://fnord.pastebin.ca/1341281复制



1> 小智..:
OS: Mac OS X 10.5.6/i386
Java: 1.5.0_16 (Apple Inc.)

Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: No details available [Built-in Microphone]
Mixer: No details available [Built-in Input]



2> JMD..:
OS: Windows XP 5.1/x86
Java: 1.6.0_12 (Sun Microsystems Inc.)

Mixer: Direct Audio Device: DirectSound Playback [Primary Sound Driver]
Mixer: Direct Audio Device: DirectSound Playback [SoundMAX Digital Audio]
Mixer: Direct Audio Device: DirectSound Capture [Primary Sound Capture Driver]
Mixer: Direct Audio Device: DirectSound Capture [SoundMAX Digital Audio]
Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: Port Mixer [Port SoundMAX Digital Audio]
  Source Port: COMPACT_DISC source port
    Control: CD Player (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: MICROPHONE source port
    Control: Microphone (compound - values below)
      Control: Select (boolean)
      Control: MIC Boost (boolean)
      Control: Mic2 Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Aux source port
    Control: Aux (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: LINE_IN source port
    Control: Line In (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Source Port: Phone source port
    Control: Phone (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Mono Out source port
    Control: Mono Out (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
  Source Port: Wave Out Mix source port
    Control: Wave Out Mix (compound - values below)
      Control: Select (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
  Target Port: SPEAKER target port
    Control: Volume (float: from 0.0 to 1.0)
    Control: Balance (float: from -1.0 to 1.0)
    Control: AC3 SPDIF (boolean)
    Control: PCM SPDIF (boolean)
    Control: Mute (boolean)
    Control: Wave (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: SW Synth (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: BassBoost (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: CD Player (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Microphone (compound - values below)
      Control: Mic2 Select (boolean)
      Control: MIC Boost (boolean)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: Aux (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Line In (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Phone (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)
    Control: Mono Out (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Mute (boolean)

注意:从http://fnord.pastebin.ca/1341281复制



3> Nik Reiman..:

正如Uri所说,Java Sound API肯定不会在Mac OS X上产生任何有趣的结果:

OS: Darwin 9.6.0/i386
Java: 1.6.0_03-p3 (Sun Microsystems Inc.)

Mixer: software mixer and synthesizer [Java Sound Audio Engine]

另外,我应该注意到我使用的是soylatte-1.0.3,而不是使用Apple的开发工具分发的相当老的JDK.



4> Ray Tayek..:
asus p5gc-mx/1333

Name    Realtek High Definition Audio
Manufacturer    Realtek
Status  OK
PNP Device ID   HDAUDIO\FUNC_01&VEN_10EC&DEV_0662&SUBSYS_10438290&REV_1001\4&18A64267&0&0001
Driver  c:\windows\system32\drivers\rtkhdaud.sys (5.10.0.5506 built by: WinDDK, 4.41 MB (4,620,288 bytes), 12/23/2008 5:14 PM)


OS: Windows XP 5.1/x86
Java: 1.6.0_11 (Sun Microsystems Inc.)

Mixer: Direct Audio Device: DirectSound Playback [Primary Sound Driver]
Mixer: Direct Audio Device: DirectSound Playback [Realtek HD Audio output]
Mixer: Direct Audio Device: DirectSound Capture [Primary Sound Capture Driver]
Mixer: Direct Audio Device: DirectSound Capture [Realtek HD Audio Input]
Mixer: Software mixer and synthesizer [Java Sound Audio Engine]
Mixer: Port Mixer [Port Realtek HD Audio output]
  Target Port: SPEAKER target port
    Control: Volume (float: from 0.0 to 1.0)
    Control: Balance (float: from -1.0 to 1.0)
    Control: Mute (boolean)
    Control: Wave (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: SW Synth (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Front (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
    Control: Rear (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
    Control: Subwoofer (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
    Control: Center (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
    Control: SPDIF (compound - values below)
      Control: Mute (boolean)
    Control: Line Volume (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
    Control: Mic Volume (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Microphone Boost (boolean)
      Control: Mute (boolean)
    Control: CD Volume (compound - values below)
      Control: Volume (float: from 0.0 to 1.0)
      Control: Balance (float: from -1.0 to 1.0)
      Control: Mute (boolean)
Mixer: Port Mixer [Port Realtek HD Audio Input]
  Source Port: COMPACT_DISC source port
    Control: CD Volume (compound - values below)
      Control: Mute (boolean)
  Source Port: LINE_IN source port
    Control: Line Volume (compound - values below)
      Control: Mute (boolean)
  Source Port: MICROPHONE source port
    Control: Mic Volume (compound - values below)
      Control: Mute (boolean)
  Source Port: Stereo Mix source port
    Control: Stereo Mix (compound - values below)
      Control: Mute (boolean)
  Target Port: Recording Control target port
    Control: Volume (float: from 0.0 to 1.0)
    Control: Balance (float: from -1.0 to 1.0)
    Control: Mute (boolean)
    Control: CD Volume (compound - values below)
      Control: Mute (boolean)
    Control: Line Volume (compound - values below)
      Control: Mute (boolean)
    Control: Mic Volume (compound - values below)
      Control: Mute (boolean)
    Control: Stereo Mix (compound - values below)
      Control: Mute (boolean)

推荐阅读
pan2502851807
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有