本文整理汇总了Java中javax.sound.sampled.FloatControl.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于javax.sound.sampled.FloatControl包,在下文中一共展示了Type类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeDataToLine
import javax.sound.sampled.FloatControl.Type; //导入依赖的package包/类
private void writeDataToLine() throws LineUnavailableException {
playing = true;
line = AudioSystem.getSourceDataLine(format);
if (line == null) {
return;
}
line.open();
line.start();
for (int i = 0; i < data.length && playing; i += BUFFER_SIZE) {
if (line.isControlSupported(Type.MASTER_GAIN)) {
final FloatControl gainControl = (FloatControl)line.getControl(Type.MASTER_GAIN);
final float minimum = gainControl.getMinimum();
final float maximum = gainControl.getMaximum();
final float actualGain = Math.max(minimum, Math.min(maximum, gain));
gainControl.setValue(actualGain);
}
if (i + BUFFER_SIZE > data.length) {
i = data.length - BUFFER_SIZE;
}
line.write(data, i, BUFFER_SIZE);
}
line.drain();
}
示例2: setPanning
import javax.sound.sampled.FloatControl.Type; //导入依赖的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);
}
}
示例3: createDataLineForChannel
import javax.sound.sampled.FloatControl.Type; //导入依赖的package包/类
/** This one will only create datalines for common clip/audioline samples
* directly.
*
* @param c
* @param sfxid
*/
private final void createDataLineForChannel(int c, int sfxid){
// None? Make a new one.
if (channels[c].auline == null) {
try {
DoomSound tmp=cachedSounds.get(sfxid);
// Sorry, Charlie. Gotta make a new one.
DataLine.Info info = new DataLine.Info(SourceDataLine.class, DoomSound.DEFAULT_SAMPLES_FORMAT);
channels[c].auline = (SourceDataLine) AudioSystem.getLine(info);
channels[c].auline.open(tmp.format);
} catch (LineUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
boolean errors=false;
// Add individual volume control.
if (channels[c].auline.isControlSupported(Type.MASTER_GAIN))
channels[c].vc=(FloatControl) channels[c].auline
.getControl(Type.MASTER_GAIN);
else {
System.err.print("MASTER_GAIN, ");
errors=true;
if (channels[c].auline.isControlSupported(Type.VOLUME))
channels[c].vc=(FloatControl) channels[c].auline
.getControl(Type.VOLUME);
else
System.err.print("VOLUME, ");
}
// Add individual pitch control.
if (channels[c].auline.isControlSupported(Type.SAMPLE_RATE)){
channels[c].pc=(FloatControl) channels[c].auline
.getControl(Type.SAMPLE_RATE);
} else {
errors=true;
System.err.print("SAMPLE_RATE, ");
}
// Add individual pan control
if (channels[c].auline.isControlSupported(Type.BALANCE)){
channels[c].bc=(FloatControl) channels[c].auline
.getControl(FloatControl.Type.BALANCE);
} else {
System.err.print("BALANCE, ");
errors=true;
if (channels[c].auline.isControlSupported(Type.PAN)){
channels[c].bc=(FloatControl) channels[c].auline
.getControl(FloatControl.Type.PAN);
} else {
System.err.print("PANNING ");
}
}
if (errors) System.err.printf("for channel %d NOT supported!\n",c);
channels[c].auline.start();
}
}