javax.sound.sampled.Mixer.getSourceLineInfo()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中javax.sound.sampled.Mixer.getSourceLineInfo()方法的一些代码示例,展示了Mixer.getSourceLineInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mixer.getSourceLineInfo()方法的具体详情如下:
包路径:javax.sound.sampled.Mixer
类名称:Mixer
方法名:getSourceLineInfo

Mixer.getSourceLineInfo介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (Mixer.Info info: mixerInfos){
Mixer m = AudioSystem.getMixer(info);
Line.Info[] lineInfos = m.getSourceLineInfo();
for (Line.Info lineInfo:lineInfos){
 System.out.println (info.getName()+"---"+lineInfo);
 Line line = m.getLine(lineInfo);
 System.out.println("\t-----"+line);
}
lineInfos = m.getTargetLineInfo();
for (Line.Info lineInfo:lineInfos){
 System.out.println (m+"---"+lineInfo);
 Line line = m.getLine(lineInfo);
 System.out.println("\t-----"+line);
}
}

代码示例来源:origin: marytts/marytts

/**
 * Try to get a line for output to the speaker. The line is not yet opened with a specific format.
 * 
 * @return a line object, or null if the line could not be created.
 */
public SourceDataLine getSpeakerOutputLine() {
  Object audioDescriptor = cbSpeakerOutput.getSelectedItem();
  assert audioDescriptor instanceof Mixer.Info;
  Mixer.Info mixerInfo = (Mixer.Info) audioDescriptor;
  Mixer mixer = AudioSystem.getMixer(mixerInfo);
  Line.Info[] lineInfos = mixer.getSourceLineInfo();
  assert lineInfos.length > 0 : "Strange, there are no more source lines for mixer: " + mixer;
  Line.Info lineInfo = lineInfos[0];
  SourceDataLine line = null;
  try {
    line = (SourceDataLine) mixer.getLine(lineInfo);
  } catch (LineUnavailableException e) {
    e.printStackTrace();
  }
  return line;
}

代码示例来源:origin: marytts/marytts

/**
 * Try to get a line for output to the expert. The line is not yet opened with a specific format.
 * 
 * @return a line object, or null if the line could not be created.
 */
public SourceDataLine getExpertOutputLine() {
  Object audioDescriptor = cbExpertOutput.getSelectedItem();
  assert audioDescriptor instanceof Mixer.Info;
  Mixer.Info mixerInfo = (Mixer.Info) audioDescriptor;
  Mixer mixer = AudioSystem.getMixer(mixerInfo);
  Line.Info[] lineInfos = mixer.getSourceLineInfo();
  assert lineInfos.length > 0 : "Strange, there are no more source lines for mixer: " + mixer;
  Line.Info lineInfo = lineInfos[0];
  SourceDataLine line = null;
  try {
    line = (SourceDataLine) mixer.getLine(lineInfo);
  } catch (LineUnavailableException e) {
    e.printStackTrace();
  }
  return line;
}

代码示例来源:origin: cmusphinx/sphinx4

private static void dumpMixers() {
  Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
  for (int i = 0; i < mixerInfo.length; i++) {
    Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
    System.out.println("Mixer[" + i + "]: \""
        + mixerInfo[i].getName() + '\"');
    System.out.println("    Description: "
        + mixerInfo[i].getDescription());
    System.out.println("    SourceLineInfo (e.g., speakers):");
    dumpLineInfo("        ", mixer.getSourceLineInfo());
    System.out.println("    TargetLineInfo (e.g., microphones):");
    dumpLineInfo("        ", mixer.getTargetLineInfo());
  }
}

代码示例来源:origin: marytts/marytts

Mixer mixer = AudioSystem.getMixer(mixerInfos[i]);
boolean hasSourceLine = false;
Line.Info[] lines = mixer.getSourceLineInfo();
for (int j = 0; j < lines.length; j++) {
  if (lines[j] instanceof DataLine.Info) {

代码示例来源:origin: stackoverflow.com

data = mergeArrays(
  "Source",
  mixer.getSourceLineInfo(),
  "Target",
  mixer.getTargetLineInfo() );
Line.Info[] source = mixer.getSourceLineInfo();
Line.Info[] target = mixer.getTargetLineInfo();
Line[] all = new Line[source.length + target.length];

代码示例来源:origin: stackoverflow.com

System.out.println("mixer name: " + mixerInfo.getName());
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info[] lineInfos = mixer.getSourceLineInfo();
for (Line.Info lineInfo : lineInfos) {
  System.out.println("  Line.Info: " + lineInfo);

代码示例来源:origin: stackoverflow.com

Mixer.Info[] mi = AudioSystem.getMixerInfo();
   for (Mixer.Info info : mi) {
     System.out.println("info: " + info);
     Mixer m = AudioSystem.getMixer(info);
     System.out.println("mixer " + m);
     Line.Info[] sl = m.getSourceLineInfo();
     for (Line.Info info2 : sl) {
       System.out.println("    info: " + info2);
       Line line = AudioSystem.getLine(info2);
       if (line instanceof SourceDataLine) {
         SourceDataLine source = (SourceDataLine) line;
         DataLine.Info i = (DataLine.Info) source.getLineInfo();
         for (AudioFormat format : i.getFormats()) {
           System.out.println("    format: " + format);
         }
       }
     }
   }

代码示例来源:origin: robo-code/robocode

private JComboBox getMixerComboBox() {
  if (mixerComboBox == null) {
    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
    Line.Info clipLineInfo = new Line.Info(Clip.class);
    Vector<Mixer.Info> mixers = new Vector<Mixer.Info>();
    for (Mixer.Info mi : mixerInfo) {
      if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) {
        mixers.add(mi);
      }
    }
    mixerComboBox = new JComboBox(mixers);
    mixerComboBox.setRenderer(new MixerInfoCellRenderer());
    mixerComboBox.addActionListener(eventHandler);
  }
  return mixerComboBox;
}

代码示例来源:origin: jtrfp/terminal-recall

@Override
public synchronized Collection<? extends AudioOutput> getOutputs() {
  final Line.Info [] lines = AudioSystem.getMixer(info).getSourceLineInfo();
  final Collection<AudioOutput> result = new ArrayList<AudioOutput>();
  for(Line.Info info:lines){
  if(info instanceof SourceDataLine.Info && info.getLineClass() != Clip.class){
    final SourceDataLine.Info sdlInfo = (SourceDataLine.Info)info;
    result.add(new JavaSoundOutput(sdlInfo, this));
  }
  }//end for(lines)
  return result;
}
@Override

代码示例来源:origin: chatty/chatty

public static List<String> getDeviceNames() {
  List<String> result = new ArrayList<>();
  try {
    for (Mixer.Info info : AudioSystem.getMixerInfo()) {
      for (Line.Info info2 : AudioSystem.getMixer(info).getSourceLineInfo()) {
        if (info2.getLineClass() == Clip.class) {
          result.add(info.getName());
        }
      }
    }
  } catch (Exception ex) {
    LOGGER.warning("Error getting list of sound devices: "+ex);
  }
  return result;
}

代码示例来源:origin: openimaj/openimaj

/**
 *     Returns a Java sound line for the given device name. Use 
 *     {@link AudioDevice#deviceName} as input to this method. Use
 *     {@link AudioUtils#getDevices()} to get an {@link AudioDevice} object.
 * 
 *    @param deviceName The device name.
 *  @param af The format 
 *    @return A Java sound line.
 *     @throws LineUnavailableException 
 */
static public SourceDataLine getJavaOutputLine( final String deviceName, 
    final AudioFormat af ) 
  throws LineUnavailableException
{
  final Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
  for( final Mixer.Info info: mixerInfo )
  {
    if( info.getName().equals( deviceName ) )
    {
      final Mixer m = AudioSystem.getMixer(info);
      if( m.getSourceLineInfo().length > 0 )
        return (SourceDataLine)AudioSystem.getLine( 
            m.getSourceLineInfo()[0] );
    }
  }
  
  return null;
}

代码示例来源:origin: org.openimaj/core-audio

/**
 *     Returns a Java sound line for the given device name. Use 
 *     {@link AudioDevice#deviceName} as input to this method. Use
 *     {@link AudioUtils#getDevices()} to get an {@link AudioDevice} object.
 * 
 *    @param deviceName The device name.
 *  @param af The format 
 *    @return A Java sound line.
 *     @throws LineUnavailableException 
 */
static public SourceDataLine getJavaOutputLine( final String deviceName, 
    final AudioFormat af ) 
  throws LineUnavailableException
{
  final Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
  for( final Mixer.Info info: mixerInfo )
  {
    if( info.getName().equals( deviceName ) )
    {
      final Mixer m = AudioSystem.getMixer(info);
      if( m.getSourceLineInfo().length > 0 )
        return (SourceDataLine)AudioSystem.getLine( 
            m.getSourceLineInfo()[0] );
    }
  }
  
  return null;
}

代码示例来源:origin: stackoverflow.com

for(Line.Info info : mixer.getSourceLineInfo()) {
  if(SourceDataLine.class.isAssignableFrom(info.getLineClass())) {
    SourceDataLine.Info info2 = (SourceDataLine.Info) info;

代码示例来源:origin: robo-code/robocode

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

代码示例来源:origin: de.sciss/sphinx4-core

private static void dumpMixers() {
  Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
  for (int i = 0; i < mixerInfo.length; i++) {
    Mixer mixer = AudioSystem.getMixer(mixerInfo[i]);
    System.out.println("Mixer[" + i + "]: \""
        + mixerInfo[i].getName() + '\"');
    System.out.println("    Description: "
        + mixerInfo[i].getDescription());
    System.out.println("    SourceLineInfo (e.g., speakers):");
    dumpLineInfo("        ", mixer.getSourceLineInfo());
    System.out.println("    TargetLineInfo (e.g., microphones):");
    dumpLineInfo("        ", mixer.getTargetLineInfo());
  }
}

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: stackoverflow.com

Line.Info [] sourceLineInfo = mixer.getSourceLineInfo();
for (Line.Info info : sourceLineInfo)
 showLineInfo(info);

代码示例来源:origin: stackoverflow.com

Line.Info [] sourceLineInfo = mixer.getSourceLineInfo();
for (Line.Info info : sourceLineInfo)

代码示例来源:origin: stackoverflow.com

try (TargetDataLine in1Line = (TargetDataLine) in1Mixer.getLine(in1Mixer.getTargetLineInfo()[0]);
    TargetDataLine in2Line = (TargetDataLine) in2Mixer.getLine(in2Mixer.getTargetLineInfo()[0]);
    SourceDataLine outLine = (SourceDataLine) outMixer.getLine(outMixer.getSourceLineInfo()[0])) {

相关文章