Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: capture soundoutput

Tags:

java

audio

Is it possible to capture soundoutput of the computer in Java?

It is possible to capture the microphone but that's not what I need, I need to capture parts of sound that the computer is playing and I can't figure it out.

Thanks

like image 604
baklap Avatar asked Nov 06 '22 11:11

baklap


1 Answers

I think it's possible only if you have virtual audiodevice (native soundcard driver with "What U Hear" feature, Virtual Audio Cable, Virtual Audio Streaming or similar). After that you just find a mixer that corresponds to virtual audiodevice and create TargetDataLine.

You can do it by modifying the following code example:

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

//select virtual audiodevice by vendor name, device name or version
Mixer.Info selectedMixerInfo = mixersInfo[0];
TargetDataLine recordLine = AudioSystem.getTargetDataLine(aAudioFormat, selectedMixerInfo);
like image 187
Dmitry Avatar answered Nov 15 '22 06:11

Dmitry