First off I’d like to say I’m new to Processing and it’s just GREAT!
I’m trying to work out if it’s possible to have shared access to an audio input device. Windows certainly supports this but the javax.sound.sampled library seems to fail if another process is using the resource.
I am using Virtual Audio Cable to route incoming audio and the Audio Repeater app provided with it to replicate audio to more than one endpoint. This allows me to hear and process the audio at the same time. Ultimately I want to use this for live VJ displays. The setup looks like this:
If I try and run it as above it crashes with an javax.sound.sampled.LineUnavailableException. If I first stop the repeater so it is not accessing the VAC line, start the Processing sketch, then start the repeater it works. So this proves that shared access to the VAC line does work. However this is painful if I want use this in a live VJ situation, particularly if I want to mix between several running sketches.
I know I could have several repeaters running to map to multiple VAC lines and then use a specific line with each sketch but that’s a pain and it means editing each sketch to connect to the right line before I use it. Not nice in a live environment.
So my question is are there any settings that define shared or exclusive access to devices within either Processing Sound or javax? I’ve not come across any but then again I’m new to Processing although I am a long term web developer.
My code:
import processing.sound.*;
AudioIn lineIn;
void setup() {
size(800, 800);
//Sound.list();
lineIn = new AudioIn(this, 0);
lineIn.start();
// Crashes when we exit setup if the VAC Audio Repeater is already connected
}
Many thanks in anticipation of someone pointing me to a solution.
Hi @matheplica, many thanks for your swift response. My Sound.list output is:
device id 0: Primary Sound Driver
max inputs : 0
max outputs: 2 (default)
device id 1: Line 1 (Virtual Audio Cable)
max inputs : 0
max outputs: 2
device id 2: Speakers (Realtek High Definition Audio)
max inputs : 0
max outputs: 2
device id 3: LG FULL HD (NVIDIA High Definition Audio)
max inputs : 0
max outputs: 2
device id 4: Line 2 (Virtual Audio Cable)
max inputs : 0
max outputs: 2
device id 5: LG FULL HD (NVIDIA High Definition Audio)
max inputs : 0
max outputs: 2
device id 6: Line 3 (Virtual Audio Cable)
max inputs : 0
max outputs: 2
device id 7: Primary Sound Capture Driver
max inputs : 2 (default)
max outputs: 0
device id 8: Line 1 (Virtual Audio Cable)
max inputs : 2
max outputs: 0
device id 9: Line 3 (Virtual Audio Cable)
max inputs : 2
max outputs: 0
device id 10: Line 2 (Virtual Audio Cable)
max inputs : 2
max outputs: 0
device id 11: Port Line 1 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
device id 12: Port Speakers (Realtek High Definiti
max inputs : 0
max outputs: 0
device id 13: Port LG FULL HD (NVIDIA High Definit
max inputs : 0
max outputs: 0
device id 14: Port Line 2 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
device id 15: Port LG FULL HD (NVIDIA High Definit
max inputs : 0
max outputs: 0
device id 16: Port Line 3 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
device id 17: Port Line 3 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
device id 18: Port Line 2 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
device id 19: Port Line 1 (Virtual Audio Cable)
max inputs : 0
max outputs: 0
As an update I can only get the sketches to run using device 0, all the others crash with the LineUnavailableException or a “java.lang.RuntimeException: Audio Input not configured in start() method” error. This is the case when the Repeater is running or not. However I have found that once I’ve got one sketch running I can start and stop others without error. Very odd!
I suspect the VAC Lines may need some other connection class or configuration, not sure about that, they should appear and act as any other audio device.