public boolean gainSupported() { return clip.isControlSupported(FloatControl.Type.MASTER_GAIN); }
public boolean pitchSupported() { return clip.isControlSupported(FloatControl.Type.SAMPLE_RATE); }
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; }
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()); } }
@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())); } }
@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())); } }
@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())); } }
@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())); } }
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()); } } }
/** * 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); }
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);
if( !clip.isControlSupported( FloatControl.Type.PAN ) ) panControl = null; else if( !clip.isControlSupported( FloatControl.Type.MASTER_GAIN ) ) if( !clip.isControlSupported( FloatControl.Type.SAMPLE_RATE ) )