Java Doc for DataLine.java in  » 6.0-JDK-Core » sound » javax » sound » sampled » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sound » javax.sound.sampled 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.sound.sampled.DataLine

DataLine
public interface DataLine extends Line(Code)
DataLine adds media-related functionality to its superinterface, Line . This functionality includes transport-control methods that start, stop, drain, and flush the audio data that passes through the line. A data line can also report the current position, volume, and audio format of the media. Data lines are used for output of audio by means of the subinterfaces SourceDataLine or Clip , which allow an application program to write data. Similarly, audio input is handled by the subinterface TargetDataLine , which allows data to be read.

A data line has an internal buffer in which the incoming or outgoing audio data is queued. The DataLine.drain() method blocks until this internal buffer becomes empty, usually because all queued data has been processed. The DataLine.flush() method discards any available queued data from the internal buffer.

A data line produces LineEvent.Type.START START and LineEvent.Type.STOP STOP events whenever it begins or ceases active presentation or capture of data. These events can be generated in response to specific requests, or as a result of less direct state changes. For example, if DataLine.start() is called on an inactive data line, and data is available for capture or playback, a START event will be generated shortly, when data playback or capture actually begins. Or, if the flow of data to an active data line is constricted so that a gap occurs in the presentation of data, a STOP event is generated.

Mixers often support synchronized control of multiple data lines. Synchronization can be established through the Mixer interface's Mixer.synchronize synchronize method. See the description of the Mixer Mixer interface for a more complete description.
author:
   Kara Kytle
version:
   1.40, 07/05/05
See Also:   LineEvent
since:
   1.3


Inner Class :public static class Info extends Line.Info



Method Summary
public  intavailable()
     Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer.
public  voiddrain()
     Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied. This method blocks until the draining is complete.
public  voidflush()
     Flushes queued data from the line.
public  intgetBufferSize()
     Obtains the maximum number of bytes of data that will fit in the data line's internal buffer.
public  AudioFormatgetFormat()
     Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.

If the line is not open and has never been opened, it returns the default format.

public  intgetFramePosition()
     Obtains the current position in the audio data, in sample frames. The frame position measures the number of sample frames captured by, or rendered from, the line since it was opened. This return value will wrap around after 2^31 frames.
public  floatgetLevel()
     Obtains the current volume level for the line.
public  longgetLongFramePosition()
     Obtains the current position in the audio data, in sample frames.
public  longgetMicrosecondPosition()
     Obtains the current position in the audio data, in microseconds. The microsecond position measures the time corresponding to the number of sample frames captured by, or rendered from, the line since it was opened. The level of precision is not guaranteed.
public  booleanisActive()
     Indicates whether the line is engaging in active I/O (such as playback or capture).
public  booleanisRunning()
     Indicates whether the line is running.
public  voidstart()
     Allows a line to engage in data I/O.
public  voidstop()
     Stops the line.



Method Detail
available
public int available()(Code)
Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer. For a source data line, this is the amount of data that can be written to the buffer without blocking. For a target data line, this is the amount of data available to be read by the application. For a clip, this value is always 0 because the audio data is loaded into the buffer when the clip is opened, and persists without modification until the clip is closed.

Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data.

An application is guaranteed that a read or write operation of up to the number of bytes returned from available() will not block; however, there is no guarantee that attempts to read or write more data will block. the amount of data available, in bytes




drain
public void drain()(Code)
Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied. This method blocks until the draining is complete. Because this is a blocking method, it should be used with care. If drain() is invoked on a stopped line that has data in its queue, the method will block until the line is running and the data queue becomes empty. If drain() is invoked by one thread, and another continues to fill the data queue, the operation will not complete. This method always returns when the data line is closed.
See Also:   DataLine.flush()



flush
public void flush()(Code)
Flushes queued data from the line. The flushed data is discarded. In some cases, not all queued data can be discarded. For example, a mixer can flush data from the buffer for a specific input line, but any unplayed data already in the output buffer (the result of the mix) will still be played. You can invoke this method after pausing a line (the normal case) if you want to skip the "stale" data when you restart playback or capture. (It is legal to flush a line that is not stopped, but doing so on an active line is likely to cause a discontinuity in the data, resulting in a perceptible click.)
See Also:   DataLine.stop()
See Also:   DataLine.drain()



getBufferSize
public int getBufferSize()(Code)
Obtains the maximum number of bytes of data that will fit in the data line's internal buffer. For a source data line, this is the size of the buffer to which data can be written. For a target data line, it is the size of the buffer from which data can be read. Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data. the size of the buffer in bytes



getFormat
public AudioFormat getFormat()(Code)
Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.

If the line is not open and has never been opened, it returns the default format. The default format is an implementation specific audio format, or, if the DataLine.Info object, which was used to retrieve this DataLine, specifies at least one fully qualified audio format, the last one will be used as the default format. Opening the line with a specific audio format (e.g. SourceDataLine.open(AudioFormat) ) will override the default format. current audio data format
See Also:   AudioFormat




getFramePosition
public int getFramePosition()(Code)
Obtains the current position in the audio data, in sample frames. The frame position measures the number of sample frames captured by, or rendered from, the line since it was opened. This return value will wrap around after 2^31 frames. It is recommended to use getLongFramePosition instead. the number of frames already processed since the line was opened
See Also:   DataLine.getLongFramePosition()



getLevel
public float getLevel()(Code)
Obtains the current volume level for the line. This level is a measure of the signal's current amplitude, and should not be confused with the current setting of a gain control. The range is from 0.0 (silence) to 1.0 (maximum possible amplitude for the sound waveform). The units measure linear amplitude, not decibels. the current amplitude of the signal in this line, orAudioSystem.NOT_SPECIFIED



getLongFramePosition
public long getLongFramePosition()(Code)
Obtains the current position in the audio data, in sample frames. The frame position measures the number of sample frames captured by, or rendered from, the line since it was opened. the number of frames already processed since the line was opened
since:
   1.5



getMicrosecondPosition
public long getMicrosecondPosition()(Code)
Obtains the current position in the audio data, in microseconds. The microsecond position measures the time corresponding to the number of sample frames captured by, or rendered from, the line since it was opened. The level of precision is not guaranteed. For example, an implementation might calculate the microsecond position from the current frame position and the audio sample frame rate. The precision in microseconds would then be limited to the number of microseconds per sample frame. the number of microseconds of data processed since the line was opened



isActive
public boolean isActive()(Code)
Indicates whether the line is engaging in active I/O (such as playback or capture). When an inactive line becomes active, it sends a LineEvent.Type.START START event to its listeners. Similarly, when an active line becomes inactive, it sends a LineEvent.Type.STOP STOP event. true if the line is actively capturing or renderingsound, otherwise false
See Also:   DataLine.isOpen
See Also:   DataLine.addLineListener
See Also:   DataLine.removeLineListener
See Also:   LineEvent
See Also:   LineListener



isRunning
public boolean isRunning()(Code)
Indicates whether the line is running. The default is false. An open line begins running when the first data is presented in response to an invocation of the start method, and continues until presentation ceases in response to a call to stop or because playback completes. true if the line is running, otherwise false
See Also:   DataLine.start()
See Also:   DataLine.stop()



start
public void start()(Code)
Allows a line to engage in data I/O. If invoked on a line that is already running, this method does nothing. Unless the data in the buffer has been flushed, the line resumes I/O starting with the first frame that was unprocessed at the time the line was stopped. When audio capture or playback starts, a LineEvent.Type.START START event is generated.
See Also:   DataLine.stop()
See Also:   DataLine.isRunning()
See Also:   LineEvent



stop
public void stop()(Code)
Stops the line. A stopped line should cease I/O activity. If the line is open and running, however, it should retain the resources required to resume activity. A stopped line should retain any audio data in its buffer instead of discarding it, so that upon resumption the I/O can continue where it left off, if possible. (This doesn't guarantee that there will never be discontinuities beyond the current buffer, of course; if the stopped condition continues for too long, input or output samples might be dropped.) If desired, the retained data can be discarded by invoking the flush method. When audio capture or playback stops, a LineEvent.Type.STOP STOP event is generated.
See Also:   DataLine.start()
See Also:   DataLine.isRunning()
See Also:   DataLine.flush()
See Also:   LineEvent



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.