public class

SoftMixingMixer

extends Object
implements Mixer
java.lang.Object
   ↳ com.sun.media.sound.SoftMixingMixer

Class Overview

Software audio mixer

Summary

Constants
String INFO_DESCRIPTION
String INFO_NAME
String INFO_VENDOR
String INFO_VERSION
Fields
protected Object control_mutex
protected boolean implicitOpen
protected static final Mixer.Info info
Public Constructors
SoftMixingMixer()
Public Methods
void addLineListener(LineListener listener)
Adds a listener to this line.
void close()
Closes the line, indicating that any system resources in use by the line can be released.
Control getControl(Control.Type control)
Obtains a control of the specified type, if there is any.
Control[] getControls()
Obtains the set of controls associated with this line.
AudioFormat getFormat()
long getLatency()
Line getLine(Line.Info info)
Obtains a line that is available for use and that matches the description in the specified Line.Info object.
Line.Info getLineInfo()
Obtains the Line.Info object describing this line.
int getMaxLines(Line.Info info)
Obtains the approximate maximum number of lines of the requested type that can be open simultaneously on the mixer.
Mixer.Info getMixerInfo()
Obtains information about this mixer, including the product's name, version, vendor, etc.
Info[] getSourceLineInfo(Line.Info info)
Obtains information about source lines of a particular type supported by the mixer.
Info[] getSourceLineInfo()
Obtains information about the set of source lines supported by this mixer.
Line[] getSourceLines()
Obtains the set of all source lines currently open to this mixer.
Info[] getTargetLineInfo(Line.Info info)
Obtains information about target lines of a particular type supported by the mixer.
Info[] getTargetLineInfo()
Obtains information about the set of target lines supported by this mixer.
Line[] getTargetLines()
Obtains the set of all target lines currently open from this mixer.
boolean isControlSupported(Control.Type control)
Indicates whether the line supports a control of the specified type.
boolean isLineSupported(Line.Info info)
Indicates whether the mixer supports a line (or lines) that match the specified Line.Info object.
boolean isOpen()
Indicates whether the line is open, meaning that it has reserved system resources and is operational, although it might not currently be playing or capturing sound.
boolean isSynchronizationSupported(Line[] lines, boolean maintainSync)
Reports whether this mixer supports synchronization of the specified set of lines.
void open(SourceDataLine line)
void open()
Opens the line, indicating that it should acquire any required system resources and become operational.
AudioInputStream openStream(AudioFormat targetFormat)
void removeLineListener(LineListener listener)
Removes the specified listener from this line's list of listeners.
void synchronize(Line[] lines, boolean maintainSync)
Synchronizes two or more lines.
void unsynchronize(Line[] lines)
Releases synchronization for the specified lines.
Protected Methods
float getControlRate()
SoftMixingMainMixer getMainMixer()
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.sound.sampled.Line
From interface javax.sound.sampled.Mixer

Constants

protected static final String INFO_DESCRIPTION

Constant Value: "Software Sound Mixer"

protected static final String INFO_NAME

Constant Value: "Gervill Sound Mixer"

protected static final String INFO_VENDOR

Constant Value: "OpenJDK Proposal"

protected static final String INFO_VERSION

Constant Value: "1.0"

Fields

protected Object control_mutex

protected boolean implicitOpen

protected static final Mixer.Info info

Public Constructors

public SoftMixingMixer ()

Public Methods

public void addLineListener (LineListener listener)

Adds a listener to this line. Whenever the line's status changes, the listener's update() method is called with a LineEvent object that describes the change.

Parameters
listener the object to add as a listener to this line

public void close ()

Closes the line, indicating that any system resources in use by the line can be released. If this operation succeeds, the line is marked closed and a CLOSE event is dispatched to the line's listeners.

public Control getControl (Control.Type control)

Obtains a control of the specified type, if there is any. Some controls may only be available when the line is open.

Parameters
control the type of the requested control
Returns
  • a control of the specified type

public Control[] getControls ()

Obtains the set of controls associated with this line. Some controls may only be available when the line is open. If there are no controls, this method returns an array of length 0.

Returns
  • the array of controls

public AudioFormat getFormat ()

public long getLatency ()

public Line getLine (Line.Info info)

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

public Line.Info getLineInfo ()

Obtains the Line.Info object describing this line.

Returns
  • description of the line

public int getMaxLines (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

public 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

public Info[] getSourceLineInfo (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.

public 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.

public 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.

public Info[] getTargetLineInfo (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.

public 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.

public 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.

public boolean isControlSupported (Control.Type control)

Indicates whether the line supports a control of the specified type. Some controls may only be available when the line is open.

Parameters
control the type of the control for which support is queried
Returns
  • true if at least one control of the specified type is supported, otherwise false.

public boolean isLineSupported (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

public boolean isOpen ()

Indicates whether the line is open, meaning that it has reserved system resources and is operational, although it might not currently be playing or capturing sound.

Returns
  • true if the line is open, otherwise false

public boolean isSynchronizationSupported (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

public void open (SourceDataLine line)

public void open ()

Opens the line, indicating that it should acquire any required system resources and become operational. If this operation succeeds, the line is marked as open, and an OPEN event is dispatched to the line's listeners.

Note that some lines, once closed, cannot be reopened. Attempts to reopen such a line will always result in an LineUnavailableException.

Some types of lines have configurable properties that may affect resource allocation. For example, a DataLine must be opened with a particular format and buffer size. Such lines should provide a mechanism for configuring these properties, such as an additional open method or methods which allow an application to specify the desired settings.

This method takes no arguments, and opens the line with the current settings. For SourceDataLine and TargetDataLine objects, this means that the line is opened with default settings. For a Clip, however, the buffer size is determined when data is loaded. Since this method does not allow the application to specify any data to load, an IllegalArgumentException is thrown. Therefore, you should instead use one of the open methods provided in the Clip interface to load data into the Clip.

For DataLine's, if the DataLine.Info object which was used to retrieve the line, specifies at least one fully qualified audio format, the last one will be used as the default format.

public AudioInputStream openStream (AudioFormat targetFormat)

public void removeLineListener (LineListener listener)

Removes the specified listener from this line's list of listeners.

Parameters
listener listener to remove

public void synchronize (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

public void unsynchronize (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

Protected Methods

protected float getControlRate ()

protected SoftMixingMainMixer getMainMixer ()