javax.sound.sampled
Interface Mixer

All Superinterfaces:
Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line

public interface Mixer
extends Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line

A mixer is an audio device with one or more lines. It need not be designed for mixing audio signals. A mixer that actually mixes audio has multiple input (source) lines and at least one output (target) line. The former are often instances of classes that implement SourceDataLine sample code for javax.sound.sampled.SourceDataLine definition code for javax.sound.sampled.SourceDataLine , and the latter, TargetDataLine sample code for javax.sound.sampled.TargetDataLine definition code for javax.sound.sampled.TargetDataLine . Port sample code for javax.sound.sampled.Port definition code for javax.sound.sampled.Port objects, too, are either source lines or target lines. A mixer can accept prerecorded, loopable sound as input, by having some of its source lines be instances of objects that implement the Clip sample code for javax.sound.sampled.Clip definition code for javax.sound.sampled.Clip interface.

Through methods of the Line interface, which Mixer extends, a mixer might provide a set of controls that are global to the mixer. For example, the mixer can have a master gain control. These global controls are distinct from the controls belonging to each of the mixer's individual lines.

Some mixers, especially those with internal digital mixing capabilities, may provide additional capabilities by implementing the DataLine interface.

A mixer can support synchronization of its lines. When one line in a synchronized group is started or stopped, the other lines in the group automatically start or stop simultaneously with the explicitly affected one.

Since:
1.3

Nested Class Summary
static class Mixer.Info sample code for javax.sound.sampled.Mixer.Info definition code for javax.sound.sampled.Mixer.Info
          The Mixer.Info class represents information about an audio mixer, including the product's name, version, and vendor, along with a textual description.
 
Method Summary
 Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line getLine sample code for javax.sound.sampled.Mixer.getLine(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getLine(javax.sound.sampled.Line.Info) (Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
          Obtains a line that is available for use and that matches the description in the specified Line.Info object.
 int getMaxLines sample code for javax.sound.sampled.Mixer.getMaxLines(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getMaxLines(javax.sound.sampled.Line.Info) (Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
          Obtains the approximate maximum number of lines of the requested type that can be open simultaneously on the mixer.
 Mixer.Info sample code for javax.sound.sampled.Mixer.Info definition code for javax.sound.sampled.Mixer.Info getMixerInfo sample code for javax.sound.sampled.Mixer.getMixerInfo() definition code for javax.sound.sampled.Mixer.getMixerInfo() ()
          Obtains information about this mixer, including the product's name, version, vendor, etc.
 Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getSourceLineInfo sample code for javax.sound.sampled.Mixer.getSourceLineInfo() definition code for javax.sound.sampled.Mixer.getSourceLineInfo() ()
          Obtains information about the set of source lines supported by this mixer.
 Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getSourceLineInfo sample code for javax.sound.sampled.Mixer.getSourceLineInfo(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getSourceLineInfo(javax.sound.sampled.Line.Info) (Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
          Obtains information about source lines of a particular type supported by the mixer.
 Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] getSourceLines sample code for javax.sound.sampled.Mixer.getSourceLines() definition code for javax.sound.sampled.Mixer.getSourceLines() ()
          Obtains the set of all source lines currently open to this mixer.
 Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getTargetLineInfo sample code for javax.sound.sampled.Mixer.getTargetLineInfo() definition code for javax.sound.sampled.Mixer.getTargetLineInfo() ()
          Obtains information about the set of target lines supported by this mixer.
 Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getTargetLineInfo sample code for javax.sound.sampled.Mixer.getTargetLineInfo(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getTargetLineInfo(javax.sound.sampled.Line.Info) (Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
          Obtains information about target lines of a particular type supported by the mixer.
 Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] getTargetLines sample code for javax.sound.sampled.Mixer.getTargetLines() definition code for javax.sound.sampled.Mixer.getTargetLines() ()
          Obtains the set of all target lines currently open from this mixer.
 boolean isLineSupported sample code for javax.sound.sampled.Mixer.isLineSupported(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.isLineSupported(javax.sound.sampled.Line.Info) (Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
          Indicates whether the mixer supports a line (or lines) that match the specified Line.Info object.
 boolean isSynchronizationSupported sample code for javax.sound.sampled.Mixer.isSynchronizationSupported(javax.sound.sampled.Line[], boolean) definition code for javax.sound.sampled.Mixer.isSynchronizationSupported(javax.sound.sampled.Line[], boolean) (Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines, boolean maintainSync)
          Reports whether this mixer supports synchronization of the specified set of lines.
 void synchronize sample code for javax.sound.sampled.Mixer.synchronize(javax.sound.sampled.Line[], boolean) definition code for javax.sound.sampled.Mixer.synchronize(javax.sound.sampled.Line[], boolean) (Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines, boolean maintainSync)
          Synchronizes two or more lines.
 void unsynchronize sample code for javax.sound.sampled.Mixer.unsynchronize(javax.sound.sampled.Line[]) definition code for javax.sound.sampled.Mixer.unsynchronize(javax.sound.sampled.Line[]) (Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines)
          Releases synchronization for the specified lines.
 
Methods inherited from interface javax.sound.sampled.Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line
addLineListener sample code for javax.sound.sampled.Line.addLineListener(javax.sound.sampled.LineListener) definition code for javax.sound.sampled.Line.addLineListener(javax.sound.sampled.LineListener) , close sample code for javax.sound.sampled.Line.close() definition code for javax.sound.sampled.Line.close() , getControl sample code for javax.sound.sampled.Line.getControl(javax.sound.sampled.Control.Type) definition code for javax.sound.sampled.Line.getControl(javax.sound.sampled.Control.Type) , getControls sample code for javax.sound.sampled.Line.getControls() definition code for javax.sound.sampled.Line.getControls() , getLineInfo sample code for javax.sound.sampled.Line.getLineInfo() definition code for javax.sound.sampled.Line.getLineInfo() , isControlSupported sample code for javax.sound.sampled.Line.isControlSupported(javax.sound.sampled.Control.Type) definition code for javax.sound.sampled.Line.isControlSupported(javax.sound.sampled.Control.Type) , isOpen sample code for javax.sound.sampled.Line.isOpen() definition code for javax.sound.sampled.Line.isOpen() , open sample code for javax.sound.sampled.Line.open() definition code for javax.sound.sampled.Line.open() , removeLineListener sample code for javax.sound.sampled.Line.removeLineListener(javax.sound.sampled.LineListener) definition code for javax.sound.sampled.Line.removeLineListener(javax.sound.sampled.LineListener)
 

Method Detail

getMixerInfo sample code for javax.sound.sampled.Mixer.getMixerInfo() definition code for javax.sound.sampled.Mixer.getMixerInfo()

Mixer.Info sample code for javax.sound.sampled.Mixer.Info definition code for javax.sound.sampled.Mixer.Info  getMixerInfo()
Obtains information about this mixer, including the product's name, version, vendor, etc.

Returns:
a mixer info object that describes this mixer
See Also:
Mixer.Info sample code for javax.sound.sampled.Mixer.Info definition code for javax.sound.sampled.Mixer.Info

getSourceLineInfo sample code for javax.sound.sampled.Mixer.getSourceLineInfo() definition code for javax.sound.sampled.Mixer.getSourceLineInfo()

Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getSourceLineInfo()
Obtains information about the set of source lines supported by this mixer. Some source lines may only be available when this mixer is open.

Returns:
array of Line.Info objects representing source lines for this mixer. If no source lines are supported, an array of length 0 is returned.

getTargetLineInfo sample code for javax.sound.sampled.Mixer.getTargetLineInfo() definition code for javax.sound.sampled.Mixer.getTargetLineInfo()

Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getTargetLineInfo()
Obtains information about the set of target lines supported by this mixer. Some target lines may only be available when this mixer is open.

Returns:
array of Line.Info objects representing target lines for this mixer. If no target lines are supported, an array of length 0 is returned.

getSourceLineInfo sample code for javax.sound.sampled.Mixer.getSourceLineInfo(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getSourceLineInfo(javax.sound.sampled.Line.Info)

Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getSourceLineInfo(Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
Obtains information about source lines of a particular type supported by the mixer. Some source lines may only be available when this mixer is open.

Parameters:
info - a Line.Info object describing lines about which information is queried
Returns:
an array of Line.Info objects describing source lines matching the type requested. If no matching source lines are supported, an array of length 0 is returned.

getTargetLineInfo sample code for javax.sound.sampled.Mixer.getTargetLineInfo(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getTargetLineInfo(javax.sound.sampled.Line.Info)

Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info [] getTargetLineInfo(Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
Obtains information about target lines of a particular type supported by the mixer. Some target lines may only be available when this mixer is open.

Parameters:
info - a Line.Info object describing lines about which information is queried
Returns:
an array of Line.Info objects describing target lines matching the type requested. If no matching target lines are supported, an array of length 0 is returned.

isLineSupported sample code for javax.sound.sampled.Mixer.isLineSupported(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.isLineSupported(javax.sound.sampled.Line.Info)

boolean isLineSupported(Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
Indicates whether the mixer supports a line (or lines) that match the specified Line.Info object. Some lines may only be supported when this mixer is open.

Parameters:
info - describes the line for which support is queried
Returns:
true if at least one matching line is supported, false otherwise

getLine sample code for javax.sound.sampled.Mixer.getLine(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getLine(javax.sound.sampled.Line.Info)

Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line  getLine(Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
             throws LineUnavailableException sample code for javax.sound.sampled.LineUnavailableException definition code for javax.sound.sampled.LineUnavailableException 
Obtains a line that is available for use and that matches the description in the specified Line.Info object.

If a DataLine is requested, and info is an instance of DataLine.Info specifying at least one fully qualified audio format, the last one will be used as the default format of the returned DataLine.

Parameters:
info - describes the desired line
Throws:
LineUnavailableException sample code for javax.sound.sampled.LineUnavailableException definition code for javax.sound.sampled.LineUnavailableException - if a matching line is not available due to resource restrictions
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this mixer does not support any lines matching the description
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a matching line is not available due to security restrictions

getMaxLines sample code for javax.sound.sampled.Mixer.getMaxLines(javax.sound.sampled.Line.Info) definition code for javax.sound.sampled.Mixer.getMaxLines(javax.sound.sampled.Line.Info)

int getMaxLines(Line.Info sample code for javax.sound.sampled.Line.Info definition code for javax.sound.sampled.Line.Info  info)
Obtains the approximate maximum number of lines of the requested type that can be open simultaneously on the mixer. Certain types of mixers do not have a hard bound and may allow opening more lines. Since certain lines are a shared resource, a mixer may not be able to open the maximum number of lines if another process has opened lines of this mixer. The requested type is any line that matches the description in the provided Line.Info object. For example, if the info object represents a speaker port, and the mixer supports exactly one speaker port, this method should return 1. If the info object represents a source data line and the mixer supports the use of 32 source data lines simultaneously, the return value should be 32. If there is no limit, this function returns AudioSystem.NOT_SPECIFIED.

Parameters:
info - a Line.Info that describes the line for which the number of supported instances is queried
Returns:
the maximum number of matching lines supported, or AudioSystem.NOT_SPECIFIED

getSourceLines sample code for javax.sound.sampled.Mixer.getSourceLines() definition code for javax.sound.sampled.Mixer.getSourceLines()

Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] getSourceLines()
Obtains the set of all source lines currently open to this mixer.

Returns:
the source lines currently open to the mixer. If no source lines are currently open to this mixer, an array of length 0 is returned.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if the matching lines are not available due to security restrictions

getTargetLines sample code for javax.sound.sampled.Mixer.getTargetLines() definition code for javax.sound.sampled.Mixer.getTargetLines()

Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] getTargetLines()
Obtains the set of all target lines currently open from this mixer.

Returns:
target lines currently open from the mixer. If no target lines are currently open from this mixer, an array of length 0 is returned.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if the matching lines are not available due to security restrictions

synchronize sample code for javax.sound.sampled.Mixer.synchronize(javax.sound.sampled.Line[], boolean) definition code for javax.sound.sampled.Mixer.synchronize(javax.sound.sampled.Line[], boolean)

void synchronize(Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines,
                 boolean maintainSync)
Synchronizes two or more lines. Any subsequent command that starts or stops audio playback or capture for one of these lines will exert the same effect on the other lines in the group, so that they start or stop playing or capturing data simultaneously.

Parameters:
lines - the lines that should be synchronized
maintainSync - true if the synchronization must be precisely maintained (i.e., the synchronization must be sample-accurate) at all times during operation of the lines , or false if precise synchronization is required only during start and stop operations
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the lines cannot be synchronized. This may occur if the lines are of different types or have different formats for which this mixer does not support synchronization, or if all lines specified do not belong to this mixer.

unsynchronize sample code for javax.sound.sampled.Mixer.unsynchronize(javax.sound.sampled.Line[]) definition code for javax.sound.sampled.Mixer.unsynchronize(javax.sound.sampled.Line[])

void unsynchronize(Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines)
Releases synchronization for the specified lines. The array must be identical to one for which synchronization has already been established; otherwise an exception may be thrown. However, null may be specified, in which case all currently synchronized lines that belong to this mixer are unsynchronized.

Parameters:
lines - the synchronized lines for which synchronization should be released, or null for all this mixer's synchronized lines
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the lines cannot be unsynchronized. This may occur if the argument specified does not exactly match a set of lines for which synchronization has already been established.

isSynchronizationSupported sample code for javax.sound.sampled.Mixer.isSynchronizationSupported(javax.sound.sampled.Line[], boolean) definition code for javax.sound.sampled.Mixer.isSynchronizationSupported(javax.sound.sampled.Line[], boolean)

boolean isSynchronizationSupported(Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line [] lines,
                                   boolean maintainSync)
Reports whether this mixer supports synchronization of the specified set of lines.

Parameters:
lines - the set of lines for which synchronization support is queried
maintainSync - true if the synchronization must be precisely maintained (i.e., the synchronization must be sample-accurate) at all times during operation of the lines , or false if precise synchronization is required only during start and stop operations
Returns:
true if the lines can be synchronized, false otherwise