What is the difference between AudioInputStream and TargetDataLine?
InputStream represents a stream of bytes that may be read from a file, URL or other data source. AudioInputStream extends InputStream with properties that are needed for interpreting audio data: the data format (an AudioFormat object) and the length of the stream in frames. An AudioInputStream instance can be wrapped around any InputStream object to provide this information. TargetDataLine is much more specific: it represents an audio line to which data is output from an audio device (represented by a Mixer object). Data recorded from an audio capture device is delivered to a TargetDataLine, from which it can be read by the application. So lines of various types (TargetDataLine, SourceDataLine, Clip, Port) are not arbitrary software objects that can be created and connected to a mixer or audio device. Rather, they are part of the mixer or device itself. The difference between AudioInputStream and TargetDataLine is mirrored by the difference between AudioOutputStream and SourceDataLine.
Related Questions
- For mixing without playback see How can I mix two (or more) AudioInputStream instances to a resulting AudioInputStream?
- Why is a SourceDataLine called "source" and a TargetDataLine called "target" though its actually the other way round?
- What is the difference between AudioInputStream and TargetDataLine?