Brad
Brad

Reputation: 163234

Multiple sound card output under Windows with Liquidsoap

Is it possible to output to multiple sound cards under Windows?

It seems that portaudio is the only way to play back through a sound card with Windows, but portaudio offers no mechanism for choosing which device to output to. Even if it did, it isn't clear that it would be possible to open multiple outputs.

Currently, I'm using a hack using VLC to output to the sound cards:

output.external(
  %mp3(bitrate=320,stereo_mode="stereo"),
  '"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" -vvv --config C:\vlc\vlcrc-remote1 -',
  remote1
)

output.external(
  %mp3(bitrate=320,stereo_mode="stereo"),
  '"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" -vvv --config C:\vlc\vlcrc-remote2 -',
  remote2
)

Each VLC profile has a different sound device set by default. Obviously this could be improved by switching to PCM, but if I can simply skip the whole external process issue completely, that would be great.

Upvotes: 0

Views: 892

Answers (1)

user1041976
user1041976

Reputation: 38

This is probably too late now...

Having been searching for this for a all night (several hours) and delving into the source code for PortAudio and Liquidsoap, I have established that LS utilises Pa_OpenDefaultStream() to open one stream only. It is not possible through LS' interface to pass a PA ID to input or output.portaudio. It will always default to device 0 which is the sound mapper (Windows default device).

However, all is not lost, in order to tell PortAudio which input/output to use, you can pass an environment variable before running LS:

set PA_RECOMMENDED_OUTPUT_DEVICE=x
set PA_RECOMMENDED_INPUT_DEVICE=x

Where x is a PA device reference. To find your device references you need a copy of pa_devs.exe (I found a copy here http://www.w1hkj.com/alpha/temp/pa_devs.exe) which when ran generates results.txt. This file contains the IDs you need. You can also get the IDs with Audacity by selecting Help>Audio Device Info.

So you could in theory do multiple outputs like this:

setenv("PA_RECOMMENDED_OUTPUT_DEVICE","13")
streamout1 = output.portaudio()
setenv("PA_RECOMMENDED_OUTPUT_DEVICE","14")
streamout2 = output.portaudio()

I don't know for definite if this will work but it's worth a go! If it doesn't work, you could always run two liquidsoap instances in different settings if this would work for your application.

Upvotes: 2

Related Questions