本文整理汇总了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();
}
示例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);
}
示例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);
}
}