类javax.sound.sampled.Line.Info源码实例Demo

下面列出了怎么用javax.sound.sampled.Line.Info的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FoxTelem   文件: SinkAudio.java
/**
 * FIXME:
 * specify the buffer size in the open(AudioFormat,int) method. A delay of 10ms-100ms will be acceptable for realtime audio. Very low latencies like will 
 * not work on all computer systems, and 100ms or more will probably be annoying for your users. A good tradeoff is, e.g. 50ms. For your audio format, 
 * 8-bit, mono at 44100Hz, a good buffer size is 2200 bytes, which is almost 50ms
 */
void initializeOutput() {
	
	DataLine.Info dataLineInfo = new DataLine.Info(  SourceDataLine.class, audioFormat);
	//line = (TargetDataLine) AudioSystem.getLine(info);
	//Mixer m = AudioSystem.getMixer(null);
	try {
		//sourceDataLine = (SourceDataLine)m.getLine(dataLineInfo);
		sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo);
		sourceDataLine.open(audioFormat);
		sourceDataLine.start();
	} catch (LineUnavailableException e) {
		// TODO Auto-generated catch block
		e.printStackTrace(Log.getWriter());
	}

}
 
源代码2 项目: tuxguitar   文件: AudioSystem.java
/** Checks if a Mixer is appropriate.
    A Mixer is considered appropriate if it support the given line type.
    If isMixingRequired is true and the line type is an output one
    (SourceDataLine, Clip), the mixer is appropriate if it supports
    at least 2 (concurrent) lines of the given type.

    @return true if the mixer is considered appropriate according to the
    rules given above, false otherwise.
 */
private static boolean isAppropriateMixer(Mixer mixer,
                                          Line.Info lineInfo,
                                          boolean isMixingRequired) {
    if (! mixer.isLineSupported(lineInfo)) {
        return false;
    }
    Class lineClass = lineInfo.getLineClass();
    if (isMixingRequired
        && (SourceDataLine.class.isAssignableFrom(lineClass) ||
            Clip.class.isAssignableFrom(lineClass))) {
        int maxLines = mixer.getMaxLines(lineInfo);
        return ((maxLines == NOT_SPECIFIED) || (maxLines > 1));
    }
    return true;
}
 
源代码3 项目: FoxTelem   文件: SinkAudio.java
public void setDevice(int position) throws LineUnavailableException, IllegalArgumentException {
	if (position == 0 || position == -1) {
		initializeOutput();
	} else {
		Mixer appMixer = mixerList[position];

		Info sdlLineInfo = new DataLine.Info(SourceDataLine.class, audioFormat);
		
		sourceDataLine = (SourceDataLine) appMixer.getLine(sdlLineInfo);
		sourceDataLine.open(audioFormat);
		sourceDataLine.start();
	}
		

}
 
源代码4 项目: tuxguitar   文件: AudioSystem.java
/** Return a Mixer with a given name from a given MixerProvider.
  This method never requires the returned Mixer to do mixing.
  @param mixerName The name of the Mixer to be returned.
  @param provider The MixerProvider to check for Mixers.
  @param info The type of line the returned Mixer is required to
  support.

  @return A Mixer matching the requirements, or null if none is found.
 */
private static Mixer getNamedMixer(String mixerName,
                                   MixerProvider provider,
                                   Line.Info info) {
    Mixer.Info[] infos = provider.getMixerInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(mixerName)) {
            Mixer mixer = provider.getMixer(infos[i]);
            if (isAppropriateMixer(mixer, info, false)) {
                return mixer;
            }
        }
    }
    return null;
}
 
源代码5 项目: FoxTelem   文件: SinkAudio.java
private static String getMixerIdString(Mixer appMixer) {
	Mixer.Info info = appMixer.getMixerInfo();
	return info.getName() + info.getDescription() + info.getVendor() + info.getVersion();
}
 
源代码6 项目: FoxTelem   文件: SourceSoundCardAudio.java
private static String getMixerIdString(Mixer appMixer) {
	Mixer.Info info = appMixer.getMixerInfo();
	return info.getName() + info.getDescription() + info.getVendor() + info.getVersion();
}
 
源代码7 项目: FoxTelem   文件: SourceSoundCardAudio.java
/**
 * Pass the combo box position and select this device
 * @param position
 * @throws LineUnavailableException
 * @throws IllegalArgumentException
 */
private void setDevice(int position) throws LineUnavailableException, IllegalArgumentException {
	//Mixer.Info[] mixers = AudioSystem.getMixerInfo();
	//AudioFormat audioFmt = getAudioFormat();

	Mixer appMixer = mixerList[position];

	Info sdlLineInfo = new DataLine.Info(TargetDataLine.class, makeAudioFormat(sampleRate));
	
	stop();

	targetDataLine = (TargetDataLine) appMixer.getLine(sdlLineInfo);

	init();

}
 
源代码8 项目: tuxguitar   文件: AudioSystem.java
/**
 * Obtains a source data line that can be used for playing back
 * audio data in the format specified by the
 * <code>AudioFormat</code> object. The returned line
 * will be provided by the default system mixer, or,
 * if not possible, by any other mixer installed in the
 * system that supports a matching
 * <code>SourceDataLine</code> object.
 *
 * <p>The returned line should be opened with the
 * <code>open(AudioFormat)</code> or
 * <code>open(AudioFormat, int)</code> method.
 *
 * <p>This is a high-level method that uses <code>getMixer</code>
 * and <code>getLine</code> internally.
 *
 * <p>The returned <code>SourceDataLine</code>'s default
 * audio format will be initialized with <code>format</code>.
 *
 * <p>If the system property
 * <code>javax.sound.sampled.SourceDataLine</code>
 * is defined or it is defined in the file &quot;sound.properties&quot;,
 * it is used to retrieve the default source data line.
 * For details, refer to the {@link AudioSystem class description}.
 *
 * @param format an <code>AudioFormat</code> object specifying
 *        the supported audio format of the returned line,
 *        or <code>null</code> for any audio format
 * @return the desired <code>SourceDataLine</code> object
 *
 * @throws LineUnavailableException if a matching source data line
 *         is not available due to resource restrictions
 * @throws SecurityException if a matching source data line
 *         is not available due to security restrictions
 * @throws IllegalArgumentException if the system does not
 *         support at least one source data line supporting the
 *         specified audio format through any installed mixer
 *
 * @see #getSourceDataLine(AudioFormat, Mixer.Info)
 * @since 1.5
 */
public static SourceDataLine getSourceDataLine(AudioFormat format)
        throws LineUnavailableException{
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
        return (SourceDataLine) AudioSystem.getLine(info);
    }