Interface Line
- All Superinterfaces:
- AutoCloseable
- All Known Subinterfaces:
- Clip,- DataLine,- Mixer,- Port,- SourceDataLine,- TargetDataLine
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.write and
 TargetDataLine.read.
 
 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.
- Since:
- 1.3
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic classALine.Infoobject contains information about a line.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddLineListener(LineListener listener) Adds a listener to this line.voidclose()Closes the line, indicating that any system resources in use by the line can be released.getControl(Control.Type control) Obtains a control of the specified type, if there is any.Control[]Obtains the set of controls associated with this line.Obtains theLine.Infoobject describing this line.booleanisControlSupported(Control.Type control) Indicates whether the line supports a control of the specified type.booleanisOpen()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.voidopen()Opens the line, indicating that it should acquire any required system resources and become operational.voidremoveLineListener(LineListener listener) Removes the specified listener from this line's list of listeners.
- 
Method Details- 
getLineInfoLine.Info getLineInfo()Obtains theLine.Infoobject describing this line.- Returns:
- description of the line
 
- 
openOpens 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 anOPENevent 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 DataLinemust be opened with a particular format and buffer size. Such lines should provide a mechanism for configuring these properties, such as an additionalopenmethod 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 SourceDataLineandTargetDataLineobjects, this means that the line is opened with default settings. For aClip, however, the buffer size is determined when data is loaded. Since this method does not allow the application to specify any data to load, anIllegalArgumentExceptionis thrown. Therefore, you should instead use one of theopenmethods provided in theClipinterface to load data into theClip.For DataLine's, if theDataLine.Infoobject 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.- Throws:
- IllegalArgumentException- if this method is called on a Clip instance
- LineUnavailableException- if the line cannot be opened due to resource restrictions
- See Also:
 
- 
closevoid 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 aCLOSEevent is dispatched to the line's listeners.- Specified by:
- closein interface- AutoCloseable
- See Also:
 
- 
isOpenboolean 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:
- trueif the line is open, otherwise- false
- See Also:
 
- 
getControlsControl[] 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
- See Also:
 
- 
isControlSupportedIndicates 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:
- trueif at least one control of the specified type is supported, otherwise- false
 
- 
getControlObtains 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
- Throws:
- IllegalArgumentException- if a control of the specified type is not supported
- See Also:
 
- 
addLineListenerAdds a listener to this line. Whenever the line's status changes, the listener'supdate()method is called with aLineEventobject that describes the change.- Parameters:
- listener- the object to add as a listener to this line
- See Also:
 
- 
removeLineListenerRemoves the specified listener from this line's list of listeners.- Parameters:
- listener- listener to remove
- See Also:
 
 
-