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


Java Clip.isControlSupported方法代码示例

本文整理汇总了Java中javax.sound.sampled.Clip.isControlSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Clip.isControlSupported方法的具体用法?Java Clip.isControlSupported怎么用?Java Clip.isControlSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.sampled.Clip的用法示例。


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

示例1: start

import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
 * Plays the clip with the specified volume.
 * @param volume the volume the play at
 * @param listener the line listener
 * @throws LineUnavailableException if a clip object is not available or
 *         if the line cannot be opened due to resource restrictions
 */
public void start(float volume, LineListener listener) throws LineUnavailableException {
	Clip clip = getClip();
	if (clip == null)
		return;

	// PulseAudio does not support Master Gain
	if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
		// set volume
		FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
		float dB = (float) (Math.log(volume) / Math.log(10.0) * 20.0);
		gainControl.setValue(dB);
	}

	if (listener != null)
		clip.addLineListener(listener);
	clip.setFramePosition(0);
	clip.start();
}
 
开发者ID:yugecin,项目名称:opsu-dance,代码行数:26,代码来源:MultiClip.java

示例2: PreloadedPlayback

import javax.sound.sampled.Clip; //导入方法依赖的package包/类
/**
 * Creates a new {@code PreloadedPlayback}. PreloadedPlayback objects will
 * always be created by their associated PreloadedAudio object.
 * <p>
 * IMPLEMENTATION NOTE: Originally, the fetching of a new {@code Line} was
 * done in the {@code run} method, however testing revealed that latency is
 * decreased if a {@code Line} is acquired ahead of time, here in the
 * constructor.
 * 
 * @param audio
 *            The {@code Audio} that created this {@code PreloadedPlayback}.
 * @param audioFormat
 *            Specifies the particular arrangement of audio data.
 * @param audioBytes
 *            Holds the audio data from which a {@code Clip} will be
 *            created.
 * @param instanceID
 *            The {@code instanceID} of this {@code PreloadedPlayback}.
 */
protected PreloadedPlayback(Audio audio, AudioFormat audioFormat,
		byte[] audioBytes, long instanceID) {
	super(audio, instanceID);
	DataLine.Info info = new DataLine.Info(Clip.class, audioFormat);
	try {
		clip = (Clip) AudioSystem.getLine(info);
		clip.open(audioFormat, audioBytes, 0, audioBytes.length);
		if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
			volCtrl = (FloatControl) clip
					.getControl(FloatControl.Type.MASTER_GAIN);
		} else {
			logger.warning("Master-Gain control is not supported."
					+ " Volume will be fixed at the default level.");
		}
	} catch (LineUnavailableException ex) {
		ex.printStackTrace();
	}
	clip.addLineListener(this);
}
 
开发者ID:cmholton,项目名称:QwickSound,代码行数:39,代码来源:PreloadedPlayback.java

示例3: setPanning

import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public void setPanning(int chan,int sep){
Clip c=channels[chan];

if (c.isControlSupported(Type.PAN)){
	FloatControl bc=(FloatControl) c.getControl(Type.PAN);
	// Q: how does Doom's sep map to stereo panning?
	// A: Apparently it's 0-255 L-R.
	float pan= bc.getMinimum()+(bc.getMaximum()-bc.getMinimum())*(float)sep/ISoundDriver.PANNING_STEPS;
	bc.setValue(pan);
	}
}
 
开发者ID:AXDOOMER,项目名称:mochadoom,代码行数:12,代码来源:ClipSFXModule.java


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