Answer the question
In order to leave comments, you need to log in
Java: Is it possible to record sound from the output of a sound card (NOT a microphone)?
Hey!
I'm trying to record the sound that goes to the output of the speakers.
Is it possible?
I didn't find any restrictions. You need to get the desired TargetDataLine and write. But I am facing IllegalArgumentException .
The code is something like this:
(Pay no attention to the syntax, this is Kotlin)
audioFormat = AudioFormat(8000f, 8, 2, true, false)
mixerInfo = AudioSystem.getMixerInfo()
mixer = AudioSystem.getMixer(mixerInfo[0]) // перепробовал все миксеры
dataLineInfo = DataLine.Info(TargetDataLine::class.java, audioFormat)
dataLine = mixer.getLine(dataLineInfo) as TargetDataLine // IllegalArgumentException
dataLine.open()
dataLine.start()
AudioSystem.write(AudioInputStream(dataLine), AudioFileFormat.Type.WAVE, File("1.wav"))
java.lang.IllegalArgumentException: Line unsupported: interface TargetDataLine supporting format PCM_SIGNED 8000.0 Hz, 8 bit, stereo, 2 bytes/frame, little-endian
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question