void implOpen() throws LineUnavailableException { if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen()."); long newID = ((PortMixer) mixer).getID(); if ((id == 0) || (newID != id) || (controls.length == 0)) { id = newID; Vector vector = new Vector(); synchronized (vector) { nGetControls(id, portIndex, vector); controls = new Control[vector.size()]; for (int i = 0; i < controls.length; i++) { controls[i] = (Control) vector.elementAt(i); } } } else { enableControls(controls, true); } if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded"); }
/** * Constructs a new AbstractMixer. * @param mixer the mixer with which this line is associated * @param controls set of supported controls */ protected AbstractMixer(Mixer.Info mixerInfo, Control[] controls, Line.Info[] sourceLineInfo, Line.Info[] targetLineInfo) { // Line.Info, AbstractMixer, Control[] super(new Line.Info(Mixer.class), null, controls); // setup the line part this.mixer = this; if (controls == null) { controls = new Control[0]; } // setup the mixer part this.mixerInfo = mixerInfo; this.sourceLineInfo = sourceLineInfo; this.targetLineInfo = targetLineInfo; }
void implOpen() throws LineUnavailableException { if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen()."); long newID = ((PortMixer) mixer).getID(); if ((id == 0) || (newID != id) || (controls.length == 0)) { id = newID; Vector<Control> vector = new Vector<>(); synchronized (vector) { nGetControls(id, portIndex, vector); controls = new Control[vector.size()]; for (int i = 0; i < controls.length; i++) { controls[i] = vector.elementAt(i); } } } else { enableControls(controls, true); } if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded"); }
/** * Constructs a new AbstractMixer. * @param mixerInfo the mixer with which this line is associated * @param controls set of supported controls */ protected AbstractMixer(Mixer.Info mixerInfo, Control[] controls, Line.Info[] sourceLineInfo, Line.Info[] targetLineInfo) { // Line.Info, AbstractMixer, Control[] super(new Line.Info(Mixer.class), null, controls); // setup the line part this.mixer = this; if (controls == null) { controls = new Control[0]; } // setup the mixer part this.mixerInfo = mixerInfo; this.sourceLineInfo = sourceLineInfo; this.targetLineInfo = targetLineInfo; }
/** * Constructs a new AbstractLine. */ protected AbstractDataLine(DataLine.Info info, AbstractMixer mixer, Control[] controls, AudioFormat format, int bufferSize) { super(info, mixer, controls); // record the default values if (format != null) { defaultFormat = format; } else { // default CD-quality defaultFormat = new AudioFormat(44100.0f, 16, 2, true, Platform.isBigEndian()); } if (bufferSize > 0) { defaultBufferSize = bufferSize; } else { // 0.5 seconds buffer defaultBufferSize = ((int) (defaultFormat.getFrameRate() / 2)) * defaultFormat.getFrameSize(); } // set the initial values to the defaults this.format = defaultFormat; this.bufferSize = defaultBufferSize; }
@Override public final String toString() { if (contents==null) { final StringBuilder contentBuilder=new StringBuilder(); for (int loop=0; loop<indent; loop++) contentBuilder.append('\t'); contentBuilder.append(subject.getLineInfo().toString()); for (final Control control : subject.getControls()) { contentBuilder.append(System.getProperty("line.separator")); contentBuilder.append(new ControlDescription(control, indent+1).toString()); } contents=contentBuilder.toString(); } return contents; }
@Override public final String toString() { if (contents==null) { final StringBuilder contentBuilder=new StringBuilder(); for (int loop=0; loop<indent; loop++) contentBuilder.append('\t'); contentBuilder.append(subject.toString()); if (subject instanceof CompoundControl) { for (final Control member : ((CompoundControl)subject).getMemberControls()) { contentBuilder.append(System.getProperty("line.separator")); contentBuilder.append(new ControlDescription(member, indent+1).toString()); } } contents=contentBuilder.toString(); } return contents; }
/** @invisible * * Prints the available controls and their ranges to the console. Not all * Controllers have all of the controls available on them so this is a way to find * out what is available. * */ public void printControls() { if (controls.length > 0) { System.out.println("Available controls are:"); for (int i = 0; i < controls.length; i++) { Control.Type type = controls[i].getType(); System.out.print(" " + type.toString()); if (type == VOLUME || type == GAIN || type == BALANCE || type == PAN) { FloatControl fc = (FloatControl) controls[i]; String shiftSupported = "does"; if (fc.getUpdatePeriod() == -1) { shiftSupported = "doesn't"; } System.out.println(", which has a range of " + fc.getMaximum() + " to " + fc.getMinimum() + " and " + shiftSupported + " support shifting."); } else { System.out.println(""); } } } else { System.out.println("There are no controls available."); } }
@Deprecated public Control getControl(Control.Type type) { for(int i = 0; i < controls.length; i++) { if ( controls[i].getType().equals(type) ) { return controls[i]; } } return null; }
private void enableControls(Control[] controls, boolean enable) { for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof BoolCtrl) { ((BoolCtrl) controls[i]).closed = !enable; } else if (controls[i] instanceof FloatCtrl) { ((FloatCtrl) controls[i]).closed = !enable; } else if (controls[i] instanceof CompoundControl) { enableControls(((CompoundControl) controls[i]).getMemberControls(), enable); } } }
/** * Constructs a new AbstractLine. * @param mixer the mixer with which this line is associated * @param controls set of supported controls */ protected AbstractLine(Line.Info info, AbstractMixer mixer, Control[] controls) { if (controls == null) { controls = new Control[0]; } this.info = info; this.mixer = mixer; this.controls = controls; }
/** * Obtains the set of controls supported by the * line. If no controls are supported, returns an * array of length 0. * @return control set */ public final Control[] getControls() { Control[] returnedArray = new Control[controls.length]; for (int i = 0; i < controls.length; i++) { returnedArray[i] = controls[i]; } return returnedArray; }