public Control[] getControls() { if (dataLine == null) { return new Control[0]; } else { return dataLine.getControls(); } }
/** Opens the line. */ protected void openLine() throws LineUnavailableException { if (m_line != null) { AudioFormat audioFormat = m_audioInputStream.getFormat(); int buffersize = lineBufferSize; if (buffersize <= 0) { buffersize = m_line.getBufferSize(); } m_lineCurrentBufferSize = buffersize; m_line.open(audioFormat, buffersize); log.info("Open Line : BufferSize=" + buffersize); /*-- Display supported controls --*/ Control[] c = m_line.getControls(); for (int p = 0; p < c.length; p++) { log.info("Controls : " + c[p].toString()); } /*-- Is Gain Control supported ? --*/ if (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN)) { m_gainControl = (FloatControl) m_line.getControl(FloatControl.Type.MASTER_GAIN); log.info( "Master Gain Control : [" + m_gainControl.getMinimum() + "," + m_gainControl.getMaximum() + "] " + m_gainControl.getPrecision()); } /*-- Is Pan control supported ? --*/ if (m_line.isControlSupported(FloatControl.Type.PAN)) { m_panControl = (FloatControl) m_line.getControl(FloatControl.Type.PAN); log.info( "Pan Control : [" + m_panControl.getMinimum() + "," + m_panControl.getMaximum() + "] " + m_panControl.getPrecision()); } } }
/** * Open the plugin. Must be called after the formats have been determined and before "process" is * called. * * <p>Open the DataLine. */ public void open() throws ResourceUnavailableException { javax.sound.sampled.AudioFormat audioFormat = convertFormat(inputFormat); logger.info("opening with javax.sound format: " + audioFormat); try { if (!inputFormat.getEncoding().equals(AudioFormat.LINEAR)) { logger.info("JavaSoundRenderer: Audio format is not linear, creating conversion"); if (inputFormat.getEncoding().equals(AudioFormat.ULAW)) codec = new net.sf.fmj.media.codec.audio.ulaw .Decoder(); // much more efficient than JavaSoundCodec else if (inputFormat.getEncoding().equals(AudioFormat.ALAW)) codec = new net.sf.fmj.media.codec.audio.alaw .Decoder(); // much more efficient than JavaSoundCodec else throw new ResourceUnavailableException( "Unsupported input format encoding: " + inputFormat.getEncoding()); // codec = new net.sf.fmj.media.codec.JavaSoundCodec(); codec.setInputFormat(inputFormat); final Format[] outputFormats = codec.getSupportedOutputFormats(inputFormat); if (outputFormats.length < 1) throw new ResourceUnavailableException( "Unable to get an output format for input format: " + inputFormat); final AudioFormat codecOutputFormat = (AudioFormat) outputFormats[0]; // TODO: choose the best quality one. codec.setOutputFormat(codecOutputFormat); audioFormat = convertFormat(codecOutputFormat); codec.open(); logger.info( "JavaSoundRenderer: Audio format is not linear, created conversion from " + inputFormat + " to " + codecOutputFormat); } sourceLine = getSourceDataLine(audioFormat); sourceLine.open(audioFormat); { FloatControl gainFloatControl = null; BooleanControl muteBooleanControl = null; try { gainFloatControl = (FloatControl) sourceLine.getControl(FloatControl.Type.MASTER_GAIN); } catch (Exception e) { e.printStackTrace(); } try { muteBooleanControl = (BooleanControl) sourceLine.getControl(BooleanControl.Type.MUTE); } catch (Exception e) { e.printStackTrace(); } // TODO add other controls JavaSoundGainControl gainControl = new JavaSoundGainControl(gainFloatControl, muteBooleanControl); controls.addControl(gainControl); } logControls(sourceLine.getControls()); } catch (LineUnavailableException e) { throw new ResourceUnavailableException(e.getMessage()); } }