Line interface represents a mono or multi-channel audio feed. A
line is an element of the digital audio "pipeline," such as a mixer, an input
or output port, or a data path into or out of a mixer.
A line can have controls, such as gain, pan, and reverb. The controls
themselves are instances of classes that extend the base Control
class. The Line interface provides two accessor methods for obtaining
the line's controls: getControls returns the entire set,
and getControl returns a single control of specified
type.
Lines exist in various states at different times. When a line opens, it
reserves system resources for itself, and when it closes, these resources are
freed for other objects or applications. The isOpen() method lets
you discover whether a line is open or closed. An open line need not be
processing data, however. Such processing is typically initiated by
subinterface methods such as
SourceDataLine. and
TargetDataLine..
You can register an object to receive notifications whenever the line's state
changes. The object must implement the LineListener interface, which
consists of the single method update. This method
will be invoked when a line opens and closes (and, if it's a DataLine
, when it starts and stops).
An object can be registered to listen to multiple lines. The event it
receives in its update method will specify which line created the
event, what type of event it was (OPEN, CLOSE, START,
or STOP), and how many sample frames the line had processed at the
time the event occurred.
LineEvent
| Modifier and Type | Class and Description |
|---|---|
| public static class | Line.
A |
| Modifier and Type | Method and Description |
|---|---|
| public void | addLineListener(LineListener
the object to add as a listener to this line listener)Adds a listener to this line. |
| public void | close()
Redeclares java. Closes the line, indicating that any system resources in use by the line can be released. |
| public Control | Returns: a control of the specified typethe type of the requested control controlObtains a control of the specified type, if there is any. |
| public Control[] | |
| public Line. | |
| public boolean | Returns: true if at least one control of the specified type is
supported, otherwise falsethe type of the control for which support is queried controlIndicates whether the line supports a control of the specified type. |
| public boolean | Returns: true if the line is open, otherwise falseIndicates 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. |
| public void | open()
Opens the line, indicating that it should acquire any required system resources and become operational. |
| public void | removeLineListener(LineListener
listener to remove listener)Removes the specified listener from this line's list of listeners. |
| addLineListener | back to summary |
|---|---|
| public void addLineListener(LineListener listener) Adds a listener to this line. Whenever the line's status changes, the
listener's
| |
| close | back to summary |
|---|---|
| public void close() Redeclares java. 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 | |
| getControl | back to summary |
|---|---|
| public Control getControl(Control. Obtains a control of the specified type, if there is any. Some controls may only be available when the line is open.
| |
| getControls | back to summary |
|---|---|
| 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.
| |
| getLineInfo | back to summary |
|---|---|
| public Line. Obtains the | |
| isControlSupported | back to summary |
|---|---|
| public boolean isControlSupported(Control. Indicates whether the line supports a control of the specified type. Some controls may only be available when the line is open. | |
| isOpen | back to summary |
|---|---|
| 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. | |
| open | back to summary |
|---|---|
| public void open() throws LineUnavailableException 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
Note that some lines, once closed, cannot be reopened. Attempts to reopen
such a line will always result in an
Some types of lines have configurable properties that may affect resource
allocation. For example, a
This method takes no arguments, and opens the line with the current
settings. For
For
| |
| removeLineListener | back to summary |
|---|---|
| public void removeLineListener(LineListener listener) Removes the specified listener from this line's list of listeners.
| |
Line.Info object contains information about a line. The only
information provided by Line.Info itself is the Java class of the
line. A subclass of Line.Info adds other kinds of information
about the line. This additional information depends on which Line
subinterface is implemented by the kind of line that the
Line.Info subclass describes.
A Line.Info can be retrieved using various methods of the
Line, Mixer, and AudioSystem interfaces. Other
such methods let you pass a Line.Info as an argument, to learn
whether lines matching the specified configuration are available and to
obtain them.
Line#getLineInfo(), Mixer#getSourceLineInfo(), Mixer#getTargetLineInfo(), Mixer#getLine(Line.Info) , Mixer#getSourceLineInfo(Line.Info) , Mixer#getTargetLineInfo(Line.Info) , Mixer#isLineSupported(Line.Info) , AudioSystem#getLine(Line.Info) , AudioSystem#getSourceLineInfo(Line.Info) , AudioSystem#getTargetLineInfo(Line.Info) , AudioSystem#isLineSupported(Line.Info)
| Modifier and Type | Field and Description |
|---|---|
| private final Class | lineClass
The class of the line described by the info object. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Class | Returns: the described line's classObtains the class of the line that this |
| public boolean | |
| public String | Returns: a string representation of the info objectOverrides java. Returns a string representation of the info object. |
| lineClass | back to summary |
|---|---|
| private final Class<?> lineClass The class of the line described by the info object. | |
| Info | back to summary |
|---|---|
| public Info(Class<?> lineClass) Constructs an info object that describes a line of the specified class. This constructor is typically used by an application to describe a desired line.
| |
| getLineClass | back to summary |
|---|---|
| public Class Obtains the class of the line that this
| |
| matches | back to summary |
|---|---|
| public boolean matches(Line. Indicates whether the specified info object matches this one. To match, the specified object must be identical to or a special case of this one. The specified info object must be either an instance of the same class as this one, or an instance of a sub-type of this one. In addition, the attributes of the specified object must be compatible with the capabilities of this one. Specifically, the routing configuration for the specified info object must be compatible with that of this one. Subclasses may add other criteria to determine whether the two objects match. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of the info object. | |