javax.sound.sampled.Clip.isControlSupported()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中javax.sound.sampled.Clip.isControlSupported()方法的一些代码示例,展示了Clip.isControlSupported()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clip.isControlSupported()方法的具体详情如下:
包路径:javax.sound.sampled.Clip
类名称:Clip
方法名:isControlSupported

Clip.isControlSupported介绍

暂无

代码示例

代码示例来源:origin: com.github.bloodshura/shurax-assets

public boolean gainSupported() {
  return clip.isControlSupported(FloatControl.Type.MASTER_GAIN);
}

代码示例来源:origin: com.github.bloodshura/shurax-assets

public boolean pitchSupported() {
  return clip.isControlSupported(FloatControl.Type.SAMPLE_RATE);
}

代码示例来源:origin: chatty/chatty

private static FloatControl getFirstAvailableControl(Clip clip,
    FloatControl.Type... types) {
  for (FloatControl.Type type : types) {
    if (clip.isControlSupported(type)) {
      return (FloatControl)clip.getControl(type);
    }
  }
  return null;
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

public Reproducao(File som, Integer endereco) throws ErroExecucaoBiblioteca
{
  this.endereco = endereco;
  try
  {
    clip = AudioSystem.getClip();
    AudioInputStream stream = criaStream(som);
    clip.open(stream);
    stream.close();
    
    if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN))
    {
      controleDeVolume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    }
  }
  catch (Exception excecao)
  {
    throw new ErroExecucaoBiblioteca("Não foi possível criar ou abrir uma linha de execução de áudio para " + som.getAbsolutePath());
  }
}

代码示例来源:origin: playn/playn

@Override
protected void setVolumeImpl(float volume) {
 if (impl.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
  FloatControl volctrl = (FloatControl) impl.getControl(FloatControl.Type.MASTER_GAIN);
  volctrl.setValue(toGain(volume, volctrl.getMinimum(), volctrl.getMaximum()));
 }
}

代码示例来源:origin: com.googlecode.playn/playn-java

@Override
protected void setVolumeImpl(float volume) {
 if (impl.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
  FloatControl volctrl = (FloatControl) impl.getControl(FloatControl.Type.MASTER_GAIN);
  volctrl.setValue(toGain(volume, volctrl.getMinimum(), volctrl.getMaximum()));
 }
}

代码示例来源:origin: threerings/playn

@Override
protected void setVolumeImpl(float volume) {
 if (impl.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
  FloatControl volctrl = (FloatControl) impl.getControl(FloatControl.Type.MASTER_GAIN);
  volctrl.setValue(toGain(volume, volctrl.getMinimum(), volctrl.getMaximum()));
 }
}

代码示例来源:origin: io.playn/playn-java-base

@Override
protected void setVolumeImpl(float volume) {
 if (impl.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
  FloatControl volctrl = (FloatControl) impl.getControl(FloatControl.Type.MASTER_GAIN);
  volctrl.setValue(toGain(volume, volctrl.getMinimum(), volctrl.getMaximum()));
 }
}

代码示例来源:origin: ru.sbtqa/monte-media

public synchronized void play() {
  stop();
  if (clip == null) {
    try {
      clip = createClip();
      clip.open(getAudioFormat(), samples.clone(), 0, samples.length);
      if (clip.isControlSupported(FloatControl.Type.PAN)) {
        FloatControl control = (FloatControl) clip.getControl(FloatControl.Type.PAN);
        control.setValue(pan);
      }
      if (clip.isControlSupported(FloatControl.Type.VOLUME)) {
        FloatControl control = (FloatControl) clip.getControl(FloatControl.Type.VOLUME);
        control.setValue(volume / 64f);
      }
      clip.start();
    } catch (LineUnavailableException e) {
      e.printStackTrace();
      throw new InternalError(e.getMessage());
    }
  }
}

代码示例来源:origin: robo-code/robocode

/**
 * Plays a specific sound at a given volume, panning and loop count
 *
 * @param key    the sound name, as stored in the sound table
 * @param pan    panning to be used (-1=left, 0=middle, +1=right)
 * @param volume volume to be used, from 0 to 1
 * @param loop   the number of times to loop the sound
 */
private void playSound(Object key, float pan, float volume, int loop) {
  Clip c = getSounds().getSound(key);
  if (c == null) {
    return;
  }
  if (properties.getOptionsSoundEnableMixerPan() && c.isControlSupported(FloatControl.Type.PAN)) {
    FloatControl panCtrl = (FloatControl) c.getControl(FloatControl.Type.PAN);
    panCtrl.setValue(pan);
  }
  if (properties.getOptionsSoundEnableMixerVolume() && c.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
    FloatControl volCtrl = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN);
    float min = volCtrl.getMinimum() / 4;
    if (volume != 1) {
      volCtrl.setValue(min * (1 - volume));
    }
  }
  c.loop(loop);
}

代码示例来源:origin: ru.sbtqa/monte-media

clip = createClip();
clip.open(getAudioFormat(), samples.clone(), 0, samples.length);
if (clip.isControlSupported(FloatControl.Type.PAN)) {
  FloatControl control = (FloatControl) clip.getControl(FloatControl.Type.PAN);
  control.setValue(pan);
if (clip.isControlSupported(FloatControl.Type.VOLUME)) {
  FloatControl control = (FloatControl) clip.getControl(FloatControl.Type.VOLUME);
  control.setValue(volume / 64f);

代码示例来源:origin: com.github.nifty-gui/nifty-pauls-soundsystem

if( !clip.isControlSupported( FloatControl.Type.PAN ) )
  panControl = null;
else
if( !clip.isControlSupported( FloatControl.Type.MASTER_GAIN ) )
if( !clip.isControlSupported( FloatControl.Type.SAMPLE_RATE ) )

相关文章