baklap
baklap

Reputation: 2173

Java: capture soundoutput

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

Upvotes: 5

Views: 1575

Answers (1)

Dmitry
Dmitry

Reputation: 1208

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);

Upvotes: 2

Related Questions