@Override public boolean isControlSupported (Control.Type control) { return dataLine.isControlSupported(control); }
@Override public boolean isControlSupported (Control.Type control) { return dataLine.isControlSupported(control); }
@Override public boolean isControlSupported (Control.Type control) { return dataLine.isControlSupported(control); }
@Override public boolean isControlSupported (Control.Type control) { return dataLine.isControlSupported(control); }
public boolean isGainSupported() { return sourceDataLine.isControlSupported(FloatControl.Type.MASTER_GAIN); }
public boolean isVolumeSupported() { return sourceDataLine.isControlSupported(FloatControl.Type.VOLUME); }
/** * Sets the volume used to play the sound. * * @param volume volume to be set */ private void setVolume( final int volume ) { if ( audioLine.isControlSupported( FloatControl.Type.MASTER_GAIN ) ) { final FloatControl volumeControl = (FloatControl) audioLine.getControl( FloatControl.Type.MASTER_GAIN ); volumeControl.setValue( 20.0f * (float) Math.log10( volume / 100.0 ) ); } }
private void initControls() { if (this.dataLine == null) { return; } // Check if panning is supported: // Create a new pan Control: this.panControl = this.dataLine.isControlSupported(FloatControl.Type.PAN) ? (FloatControl) this.dataLine.getControl(FloatControl.Type.PAN) : null; // Check if changing the volume is supported: // Create a new gain control: this.gainControl = this.dataLine.isControlSupported(FloatControl.Type.MASTER_GAIN) ? (FloatControl) this.dataLine.getControl(FloatControl.Type.MASTER_GAIN) : null; // Store it's initial gain to use as "maximum volume" later: this.setMasterGain(this.actualGain); }
/** * Returns the line's MASTER_GAIN control's value. */ private float getLineGain() { if (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN)) { /* Bound gain value by min and max declared by the control */ final FloatControl gainControl = (FloatControl)m_line.getControl(FloatControl.Type.MASTER_GAIN); return gainControl.getValue(); } else { s_logger.severe("Audio output line doesn not support volume control"); return 0.0f; } }
public void mute() { if (audioLine == null) { isMuted = true; } else { //when requesting the same line you sometimes get different features isMuted = true; if (!audioLine.isControlSupported(BooleanControl.Type.MUTE)) return; BooleanControl control = (BooleanControl) audioLine.getControl(BooleanControl.Type.MUTE); control.setValue(true); } }
public void unMute() { if (audioLine == null) { isMuted = false; } else { isMuted = false; if (!audioLine.isControlSupported(BooleanControl.Type.MUTE)) return; BooleanControl control = (BooleanControl) audioLine.getControl(BooleanControl.Type.MUTE); control.setValue(false); } }
// Added two lines. DataLine.Info info = new DataLine.Info( SourceDataLine.class, audioFormat ); SourceDataLine dataLine = (SourceDataLine) AudioSystem.getLine( info ); dataLine.open(); // Adjust the volume on the output line. if( dataLine.isControlSupported( FloatControl.Type.MASTER_GAIN)) { // If inside this if, the Master_Gain must be supported. Yes? FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN); // This line throws an exception. "Master_Gain not supported" volume.setValue( 100.0F ); }
private void setVolumeToAudio(int volume) { if (audio == null) return; if (audio.isControlSupported(FloatControl.Type.MASTER_GAIN)) { FloatControl volumeControl = (FloatControl) audio.getControl(FloatControl.Type.MASTER_GAIN); // Copied from: http://www.javadocexamples.com/java_source/com/limegroup/gnutella/gui/mp3/BasicPlayer.java.html#line.615 double minGainDB = volumeControl.getMinimum(); double ampGainDB = Math.min(.5*volumeControl.getMaximum(), 0) - volumeControl.getMinimum(); double cste = Math.log(10.0)/20; double valueDB = minGainDB + (1/cste)*Math.log(1+(Math.exp(cste*ampGainDB)-1)* (volume / 100f)); volumeControl.setValue((float)valueDB); } }
public void setMute(boolean mute) { if (sourceDataLine.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl volumeControl = (FloatControl) sourceDataLine.getControl(FloatControl.Type.VOLUME); if (mute) { volumeControl.setValue(0f); } else { volumeControl.setValue(volume); } } }
dataLine = createDataLine(); dataLine.open(); if (dataLine.isControlSupported(FloatControl.Type.BALANCE)) { FloatControl control = (FloatControl) dataLine.getControl(FloatControl.Type.BALANCE); control.setValue(pan); if (dataLine.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl control = (FloatControl) dataLine.getControl(FloatControl.Type.VOLUME); control.setValue(volume / 64f);
/** * Sets the line's MASTER_GAIN control to the provided value, * or complains to the log of the line does not support a MASTER_GAIN control * * @param gain gain to set */ private void setLineGain(final float gain) { if (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN)) { /* Bound gain value by min and max declared by the control */ final FloatControl gainControl = (FloatControl)m_line.getControl(FloatControl.Type.MASTER_GAIN); if (gain < gainControl.getMinimum()) gainControl.setValue(gainControl.getMinimum()); else if (gain > gainControl.getMaximum()) gainControl.setValue(gainControl.getMaximum()); else gainControl.setValue(gain); } else s_logger.severe("Audio output line doesn not support volume control"); }
@Override public void onActive() { if (audioLine != null) audioLine.close(); try { if (player.getMixer() != null) { log.debug("Custom mixer " + player.getMixer().getName()); audioLine = AudioSystem.getSourceDataLine(PCM, player.getMixer()); } else { audioLine = AudioSystem.getSourceDataLine(PCM); } audioLine.open(PCM, 1048576); log.debug("player.volume : " + player.getVolume()); onVolumeChanged(player.getVolume()); if (isMuted && audioLine.isControlSupported(BooleanControl.Type.MUTE)) ((BooleanControl) audioLine.getControl(BooleanControl.Type.MUTE)).setValue(true); } catch (LineUnavailableException e) { log.error("onActive error", e); } }
line.open(fmt, BUFFER_SIZE); line.start(); if (line.isControlSupported(FloatControl.Type.VOLUME)) { volumeControl = (FloatControl) line.getControl(FloatControl.Type.VOLUME); volumeControl.setValue(volume * volumeControl.getMaximum()); linearVolume = true; } else if (line.isControlSupported(FloatControl.Type.MASTER_GAIN)) { volumeControl = (FloatControl) line.getControl(FloatControl.Type.MASTER_GAIN); volumeControl.setValue(linearToDb(volume));
if (m_javaSoundLine.isControlSupported(FloatControl.Type.MASTER_GAIN)) { m_javaSoundLineControlMasterGain = (FloatControl)m_javaSoundLine.getControl(FloatControl.Type.MASTER_GAIN); m_javaSoundLineControlMasterGainMin = m_javaSoundLineControlMasterGain.getMinimum();
if (dataLine.isControlSupported(FloatControl.Type.VOLUME) && dataLine.isControlSupported(FloatControl.Type.BALANCE)) { buffer = transformData(soundDataRetriever.getSoundData(sound.getData())); FloatControl volumeControl = (FloatControl) dataLine.getControl(FloatControl.Type.VOLUME);