Java – Capturing audio output


It is required to record audio from the standard audio output (i.e. the sound that the user hears, for example, while watching a video). The main problem is that SourceDataLine does not have a read method.
My code:

AudioFormat audioFormat = new AudioFormat(48000, 16, 2, true, false);
DataLine.Info   info = new DataLine.Info(SourceDataLine.class, audioFormat);
SourceDataLine sourceDataLine = null;
    sourceDataLine = (SourceDataLine) AudioSystem.getLine(info);
    // Как считать аудио с sourceDataLine?

} catch (Exception e) {


This code helped:

Mixer.Info[] mixersInfo = AudioSystem.getMixerInfo();

Mixer.Info selectedMixerInfo = mixersInfo[0];
TargetDataLine recordLine = AudioSystem.getTargetDataLine(
    aAudioFormat, selectedMixerInfo
Scroll to Top