Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing speaker output in Java

Using Java is it possible to capture the speaker output? This output is not being generated by my program but rather by other running applications. Can this be done with Java or will I need to resort to C/C++?

like image 806
dbotha Avatar asked Jul 10 '11 23:07

dbotha


2 Answers

I had a Java based app. that used Java Sound to tap into the sound flowing through the system to make a trace of it. It worked well on my own (Windows based) machine, but failed completely on some others.

It was determined that in order to get it working on those machines, would take nothing short of an audio loop-back in either software or hardware (e.g. connect a lead from the speaker 'out' jack to the microphone 'in' jack).

Since all I really wanted to do was plot the trace for music, and I figured how to play the target format (MP3) in Java, it became unnecessary to pursue the other option further.

(And I also heard that Java Sound on Mac. was horribly broken, but I never looked closely into it.)

like image 109
Andrew Thompson Avatar answered Oct 21 '22 18:10

Andrew Thompson


Java is not the best tool when dealing with the OS. If you need/want to use it for this task, probably you will end using Java Native Interface (JNI), linking to libraries compiled in other languages (probably c/c++).

like image 33
SJuan76 Avatar answered Oct 21 '22 17:10

SJuan76