0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sound.sampled;
0N/A
0N/A
0N/A/**
0N/A * A mixer is an audio device with one or more lines. It need not be
0N/A * designed for mixing audio signals. A mixer that actually mixes audio
0N/A * has multiple input (source) lines and at least one output (target) line.
0N/A * The former are often instances of classes that implement
0N/A * <code>{@link SourceDataLine}</code>,
0N/A * and the latter, <code>{@link TargetDataLine}</code>. <code>{@link Port}</code>
0N/A * objects, too, are either source lines or target lines.
0N/A * A mixer can accept prerecorded, loopable sound as input, by having
0N/A * some of its source lines be instances of objects that implement the
0N/A * <code>{@link Clip}</code> interface.
0N/A * <p>
0N/A * Through methods of the <code>Line</code> interface, which <code>Mixer</code> extends,
0N/A * a mixer might provide a set of controls that are global to the mixer. For example,
0N/A * the mixer can have a master gain control. These global controls are distinct
0N/A * from the controls belonging to each of the mixer's individual lines.
0N/A * <p>
0N/A * Some mixers, especially
0N/A * those with internal digital mixing capabilities, may provide
0N/A * additional capabilities by implementing the <code>DataLine</code> interface.
0N/A * <p>
0N/A * A mixer can support synchronization of its lines. When one line in
0N/A * a synchronized group is started or stopped, the other lines in the group
0N/A * automatically start or stop simultaneously with the explicitly affected one.
0N/A *
0N/A * @author Kara Kytle
0N/A * @since 1.3
0N/A */
0N/Apublic interface Mixer extends Line {
0N/A
0N/A /**
0N/A * Obtains information about this mixer, including the product's name,
0N/A * version, vendor, etc.
0N/A * @return a mixer info object that describes this mixer
0N/A * @see Mixer.Info
0N/A */
0N/A public Info getMixerInfo();
0N/A
0N/A
0N/A /**
0N/A * Obtains information about the set of source lines supported
0N/A * by this mixer.
0N/A * Some source lines may only be available when this mixer is open.
0N/A * @return array of <code>Line.Info</code> objects representing source lines
0N/A * for this mixer. If no source lines are supported,
0N/A * an array of length 0 is returned.
0N/A */
0N/A public Line.Info[] getSourceLineInfo();
0N/A
0N/A /**
0N/A * Obtains information about the set of target lines supported
0N/A * by this mixer.
0N/A * Some target lines may only be available when this mixer is open.
0N/A * @return array of <code>Line.Info</code> objects representing target lines
0N/A * for this mixer. If no target lines are supported,
0N/A * an array of length 0 is returned.
0N/A */
0N/A public Line.Info[] getTargetLineInfo();
0N/A
0N/A
0N/A /**
0N/A * Obtains information about source lines of a particular type supported
0N/A * by the mixer.
0N/A * Some source lines may only be available when this mixer is open.
0N/A * @param info a <code>Line.Info</code> object describing lines about which information
0N/A * is queried
0N/A * @return an array of <code>Line.Info</code> objects describing source lines matching
0N/A * the type requested. If no matching source lines are supported, an array of length 0
0N/A * is returned.
0N/A */
0N/A public Line.Info[] getSourceLineInfo(Line.Info info);
0N/A
0N/A
0N/A /**
0N/A * Obtains information about target lines of a particular type supported
0N/A * by the mixer.
0N/A * Some target lines may only be available when this mixer is open.
0N/A * @param info a <code>Line.Info</code> object describing lines about which information
0N/A * is queried
0N/A * @return an array of <code>Line.Info</code> objects describing target lines matching
0N/A * the type requested. If no matching target lines are supported, an array of length 0
0N/A * is returned.
0N/A */
0N/A public Line.Info[] getTargetLineInfo(Line.Info info);
0N/A
0N/A
0N/A /**
0N/A * Indicates whether the mixer supports a line (or lines) that match
0N/A * the specified <code>Line.Info</code> object.
0N/A * Some lines may only be supported when this mixer is open.
0N/A * @param info describes the line for which support is queried
0N/A * @return <code>true</code> if at least one matching line is
0N/A * supported, <code>false</code> otherwise
0N/A */
0N/A public boolean isLineSupported(Line.Info info);
0N/A
0N/A /**
0N/A * Obtains a line that is available for use and that matches the description
0N/A * in the specified <code>Line.Info</code> object.
0N/A *
0N/A * <p>If a <code>DataLine</code> is requested, and <code>info</code>
0N/A * is an instance of <code>DataLine.Info</code> specifying at
0N/A * least one fully qualified audio format, the last one
0N/A * will be used as the default format of the returned
0N/A * <code>DataLine</code>.
0N/A *
0N/A * @param info describes the desired line
0N/A * @throws LineUnavailableException if a matching line
0N/A * is not available due to resource restrictions
0N/A * @throws IllegalArgumentException if this mixer does
0N/A * not support any lines matching the description
0N/A * @throws SecurityException if a matching line
0N/A * is not available due to security restrictions
0N/A */
0N/A public Line getLine(Line.Info info) throws LineUnavailableException;
0N/A
0N/A //$$fb 2002-04-12: fix for 4667258: behavior of Mixer.getMaxLines(Line.Info) method doesn't match the spec
0N/A /**
0N/A * Obtains the approximate maximum number of lines of the requested type that can be open
0N/A * simultaneously on the mixer.
0N/A *
0N/A * Certain types of mixers do not have a hard bound and may allow opening more lines.
0N/A * Since certain lines are a shared resource, a mixer may not be able to open the maximum
0N/A * number of lines if another process has opened lines of this mixer.
0N/A *
0N/A * The requested type is any line that matches the description in
0N/A * the provided <code>Line.Info</code> object. For example, if the info
0N/A * object represents a speaker
0N/A * port, and the mixer supports exactly one speaker port, this method
0N/A * should return 1. If the info object represents a source data line
0N/A * and the mixer supports the use of 32 source data lines simultaneously,
0N/A * the return value should be 32.
0N/A * If there is no limit, this function returns <code>AudioSystem.NOT_SPECIFIED</code>.
0N/A * @param info a <code>Line.Info</code> that describes the line for which
0N/A * the number of supported instances is queried
0N/A * @return the maximum number of matching lines supported, or <code>AudioSystem.NOT_SPECIFIED</code>
0N/A */
0N/A public int getMaxLines(Line.Info info);
0N/A
0N/A
0N/A /**
0N/A * Obtains the set of all source lines currently open to this mixer.
0N/A *
0N/A * @return the source lines currently open to the mixer.
0N/A * If no source lines are currently open to this mixer, an
0N/A * array of length 0 is returned.
0N/A * @throws SecurityException if the matching lines
0N/A * are not available due to security restrictions
0N/A */
0N/A public Line[] getSourceLines();
0N/A
0N/A /**
0N/A * Obtains the set of all target lines currently open from this mixer.
0N/A *
0N/A * @return target lines currently open from the mixer.
0N/A * If no target lines are currently open from this mixer, an
0N/A * array of length 0 is returned.
0N/A * @throws SecurityException if the matching lines
0N/A * are not available due to security restrictions
0N/A */
0N/A public Line[] getTargetLines();
0N/A
0N/A /**
0N/A * Synchronizes two or more lines. Any subsequent command that starts or stops
0N/A * audio playback or capture for one of these lines will exert the
0N/A * same effect on the other lines in the group, so that they start or stop playing or
0N/A * capturing data simultaneously.
0N/A *
0N/A * @param lines the lines that should be synchronized
0N/A * @param maintainSync <code>true</code> if the synchronization
0N/A * must be precisely maintained (i.e., the synchronization must be sample-accurate)
0N/A * at all times during operation of the lines , or <code>false</code>
0N/A * if precise synchronization is required only during start and stop operations
0N/A *
0N/A * @throws IllegalArgumentException if the lines cannot be synchronized.
0N/A * This may occur if the lines are of different types or have different
0N/A * formats for which this mixer does not support synchronization, or if
0N/A * all lines specified do not belong to this mixer.
0N/A */
0N/A public void synchronize(Line[] lines, boolean maintainSync);
0N/A
0N/A /**
0N/A * Releases synchronization for the specified lines. The array must
0N/A * be identical to one for which synchronization has already been
0N/A * established; otherwise an exception may be thrown. However, <code>null</code>
0N/A * may be specified, in which case all currently synchronized lines that belong
0N/A * to this mixer are unsynchronized.
0N/A * @param lines the synchronized lines for which synchronization should be
0N/A * released, or <code>null</code> for all this mixer's synchronized lines
0N/A *
0N/A * @throws IllegalArgumentException if the lines cannot be unsynchronized.
0N/A * This may occur if the argument specified does not exactly match a set
0N/A * of lines for which synchronization has already been established.
0N/A */
0N/A public void unsynchronize(Line[] lines);
0N/A
0N/A
0N/A /**
0N/A * Reports whether this mixer supports synchronization of the specified set of lines.
0N/A *
0N/A * @param lines the set of lines for which synchronization support is queried
0N/A * @param maintainSync <code>true</code> if the synchronization
0N/A * must be precisely maintained (i.e., the synchronization must be sample-accurate)
0N/A * at all times during operation of the lines , or <code>false</code>
0N/A * if precise synchronization is required only during start and stop operations
0N/A *
0N/A * @return <code>true</code> if the lines can be synchronized, <code>false</code>
0N/A * otherwise
0N/A */
0N/A public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync);
0N/A
0N/A
0N/A /**
0N/A * The <code>Mixer.Info</code> class represents information about an audio mixer,
0N/A * including the product's name, version, and vendor, along with a textual
0N/A * description. This information may be retrieved through the
0N/A * {@link Mixer#getMixerInfo() getMixerInfo}
0N/A * method of the <code>Mixer</code> interface.
0N/A *
0N/A * @author Kara Kytle
0N/A * @since 1.3
0N/A */
0N/A public static class Info {
0N/A
0N/A /**
0N/A * Mixer name.
0N/A */
6321N/A private final String name;
0N/A
0N/A /**
0N/A * Mixer vendor.
0N/A */
6321N/A private final String vendor;
0N/A
0N/A /**
0N/A * Mixer description.
0N/A */
6321N/A private final String description;
0N/A
0N/A /**
0N/A * Mixer version.
0N/A */
6321N/A private final String version;
0N/A
0N/A /**
0N/A * Constructs a mixer's info object, passing it the given
0N/A * textual information.
0N/A * @param name the name of the mixer
0N/A * @param vendor the company who manufactures or creates the hardware
0N/A * or software mixer
0N/A * @param description descriptive text about the mixer
0N/A * @param version version information for the mixer
0N/A */
0N/A protected Info(String name, String vendor, String description, String version) {
0N/A
0N/A this.name = name;
0N/A this.vendor = vendor;
0N/A this.description = description;
0N/A this.version = version;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Indicates whether two info objects are equal, returning <code>true</code> if
0N/A * they are identical.
0N/A * @param obj the reference object with which to compare this info
0N/A * object
0N/A * @return <code>true</code> if this info object is the same as the
0N/A * <code>obj</code> argument; <code>false</code> otherwise
0N/A */
0N/A public final boolean equals(Object obj) {
0N/A return super.equals(obj);
0N/A }
0N/A
0N/A /**
0N/A * Finalizes the hashcode method.
0N/A *
0N/A * @return the hashcode for this object
0N/A */
0N/A public final int hashCode() {
0N/A return super.hashCode();
0N/A }
0N/A
0N/A /**
0N/A * Obtains the name of the mixer.
0N/A * @return a string that names the mixer
0N/A */
0N/A public final String getName() {
0N/A return name;
0N/A }
0N/A
0N/A /**
0N/A * Obtains the vendor of the mixer.
0N/A * @return a string that names the mixer's vendor
0N/A */
0N/A public final String getVendor() {
0N/A return vendor;
0N/A }
0N/A
0N/A /**
0N/A * Obtains the description of the mixer.
0N/A * @return a textual description of the mixer
0N/A */
0N/A public final String getDescription() {
0N/A return description;
0N/A }
0N/A
0N/A /**
0N/A * Obtains the version of the mixer.
0N/A * @return textual version information for the mixer
0N/A */
0N/A public final String getVersion() {
0N/A return version;
0N/A }
0N/A
0N/A /**
0N/A * Provides a string representation of the mixer info.
0N/A * @return a string describing the info object
0N/A */
0N/A public final String toString() {
0N/A return (name + ", version " + version);
0N/A }
0N/A } // class Info
0N/A}