David Foerster
David Foerster

Reputation: 1540

In Java's built-in sound framework, can an audio source stream have multiple consumers?

Is there an easy way to have multiple independent, concurrent consumers to an audio source (e. g. a microphone line) inside a single Java VM instance with Java's built-in audio framework (javax.sound.sampled.*)? Since I'm using the audio processing library TarsosDSP anyway, can it be of help with that problem? Or do I need to implement my own audio mixer?

My current problem is, that I want to

  1. process an audio stream from a microphone input with TarsosDSP (to derive a spectrogram amongst other analyses) and
  2. record snippets of that stream to transcribe speech to text, which may require watching for volume threshold for automatic activation.

Upvotes: 1

Views: 236

Answers (1)

David Foerster
David Foerster

Reputation: 1540

I found some information, that partially answers my question:

1.3.2. How can I get more than one TargetDataLine?

Current implementations of the Java Sound API do not support multiple TargetDataLines for the same recording source. There are no plans to change this behaviour. If, in the future, multi-channel soundcards are supported, it may be possible to get different TargetDataLine instances for the different inputs. If you just want to "split" lines, do it in your application. See also Can I use multi-channel sound

So, that means, that at the time of writing, Java doesn't support multiple consumers on the same recording source and it likely won't be supported in the future. That leaves me to implement my own solution or find a library with an existing solution.

Upvotes: 1

Related Questions