TargetDataLine
is for reading data which does not make sense for speakers.
SourceDataLine
is used to send data to speakers. You can get this from AudioSystem.getLine()
or a Mixer
.
You need DataLine.Info
which is something like this:
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
audioFormat
is an AudioFormat instance - you can get this from an AudioInputStream
instance getFormat()
call or just construct a new instance of AudioFormat.