当前位置: 首页>>代码示例>>Java>>正文


Java Info类代码示例

本文整理汇总了Java中javax.sound.sampled.Line.Info的典型用法代码示例。如果您正苦于以下问题:Java Info类的具体用法?Java Info怎么用?Java Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Info类属于javax.sound.sampled.Line包,在下文中一共展示了Info类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAppropriateMixer

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/** 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;
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:25,代码来源:AudioSystem.java

示例2: initializeOutput

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/**
 * 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());
	}

}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:23,代码来源:SinkAudio.java

示例3: commandline

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
public static void commandline(String[] subArgs) {
	final Mixer mixer = AudioSystem.getMixer(null);
	System.out.println("Listing audio channels...");
	for(Info info: mixer.getTargetLineInfo())
	{
		DataLine.Info di=(DataLine.Info) info;
		System.out.println("Line: "+di);
		for(AudioFormat f: di.getFormats())
		{
			System.out.println("Supported format: "+f);
		}
	}
	System.out.println("Listing audio channels DONE");
}
 
开发者ID:rizsi,项目名称:rcom,代码行数:15,代码来源:ListAudio.java

示例4: getNamedMixer

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/** 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;
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:24,代码来源:AudioSystem.java

示例5: setDevice

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
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();
	}
		

}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:16,代码来源:SinkAudio.java

示例6: getMixerInfoFromName

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/**
 * Find a mixer that matches a given name.
 * 
 * @param mixerName as returned by a previous call of Mixer.Info.getName()
 * @param forRecording whether looking for a recording device (or playback otherwise). This 
 * information is needed because otherwise, mixer names are ambiguous. 
 * @return the matching Mixer.Info from AudioSystem.getMixerInfo() or null when there's no match
 * @throws Exception for multiple matches
 */
public static Mixer.Info getMixerInfoFromName(String mixerName, boolean forRecording) throws Exception{
	if (mixerName == null)
		return AudioSystem.getMixer(null).getMixerInfo();
	
	Mixer.Info [] availableMixers = AudioSystem.getMixerInfo();
	
	Mixer.Info info = null;
	
	for (Mixer.Info m : availableMixers){
		// don't consider playing mixers - otherwise, the mixer names are ambiguous
		if (!AudioSystem.getMixer(m).isLineSupported(
				forRecording ? 
						new Info(TargetDataLine.class) :
							new Info(SourceDataLine.class))){
			//System.out.println(mixerName + ": Not considering");
		
			continue;
		}
		if (m.getName().trim().equals(mixerName)){
			if (info != null){
				throw new Exception(String.format("multiple matches for \"%s\": \"%s\" and \"%s\"",
						mixerName, info, m.getName()));
			}
			info = m;
		}
	}
	return info;
}
 
开发者ID:lendlice,项目名称:crowdpp,代码行数:38,代码来源:MixerUtil.java

示例7: getClip

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
private static Clip getClip(final AudioInputStream ais) throws LineUnavailableException, IOException {
	if (log.isTraceEnabled()) log.trace(HelperLog.methodStart(ais));

	try {
		final Info info = new DataLine.Info(Clip.class, ais.getFormat());
		final Clip result = (Clip) AudioSystem.getLine(info);
		result.open(ais);

		if (log.isTraceEnabled()) log.trace(HelperLog.methodExit(result));
		return result;
	}
	finally {
		ais.close();
	}
}
 
开发者ID:slaubenberger,项目名称:wichtel,代码行数:16,代码来源:HelperSound.java

示例8: getMixerIdString

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
private static String getMixerIdString(Mixer appMixer) {
	Mixer.Info info = appMixer.getMixerInfo();
	return info.getName() + info.getDescription() + info.getVendor() + info.getVersion();
}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:5,代码来源:SinkAudio.java

示例9: setDevice

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/**
 * 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();

}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:22,代码来源:SourceSoundCardAudio.java

示例10: getSourceDataLine

import javax.sound.sampled.Line.Info; //导入依赖的package包/类
/**
 * 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);
    }
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:47,代码来源:AudioSystem.java


注:本文中的javax.sound.sampled.Line.Info类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。