Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selecting multiple devices as in and/or out (Windows) #29

Open
davrandom opened this issue Jul 14, 2016 · 22 comments
Open

selecting multiple devices as in and/or out (Windows) #29

davrandom opened this issue Jul 14, 2016 · 22 comments
Labels

Comments

@davrandom
Copy link

Use case: two devices with m and n channels (in and/or out). I want to use the channels of both (m+n) to output and/or record.
Is this possible?

The real use case is less weird than this, I'm on windows and WDM is splitting a multichannel interface into several separated interfaces.

ps: And yes: asio would solve the problem, but I'm under cygwin and cygwin's portaudio doesn't have asio support apparently. There are other solutions, like using conda/anaconda, there it works. Anyway I think the question still makes sense.

@mgeier
Copy link
Member

mgeier commented Jul 15, 2016

PortAudio's "streams" can at most have one input device and one output device. AFAIK, PortAudio provides no means for combining multiple devices into a single new one.

You can try to use one stream per device (which may or may not work depending on the host API in use), but it will be hard (or impossible?) to start and stop them at the exact same time.

I don't know much about Windows and even less about Cygwin. I assume the bundled DLL doesn't work there?

What about the other host APIs for Windows? Which of them are available?

Why does it work with Anaconda? Are you using Anaconda within Cygwin? Is this even possible?

@davrandom
Copy link
Author

"such many questions
no expert
wow"

(sorry I couldn't resist)

Thanks for the information about the impossibility for portaudio to aggregate devices. This rules out one option, and possibly this issue.

I don't know the answer to essentially any of these questions, but I guess conda works because it's using the asio driver that resides natively in win, while cygwin is somewhat abstracted/separated from the native win layer. Not sure if this makes sense, but it's my feeling.
The only solution I see is having success in compiling portaudio with asio support in cygwin. (Or move to conda.)

Thanks for your time and sorry for the "silly" question.

@mgeier
Copy link
Member

mgeier commented Jul 19, 2016

I don't think that's a silly question. All those operating systems and audio backends are really confusing ...

If you find anything new, please share it here!

Just out of curiosity, could you please share the device list which you get when running on Cygwin?

@davrandom
Copy link
Author

(sorry I was traveling and I didn't have the madiface with me...)

In [3]: sd.query_devices()
Out[3]:
   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Microphone Array (IDT High Defi, MME (2 in, 0 out)
   2 MADI (25-32) (RME MADIface USB), MME (2 in, 0 out)
   3 MADI (33-40) (RME MADIface USB), MME (2 in, 0 out)
   4 MADI (57-64) (RME MADIface USB), MME (2 in, 0 out)
   5 Jack Mic (IDT High Definition A, MME (2 in, 0 out)
   6 MADI (17-24) (RME MADIface USB), MME (2 in, 0 out)
   7 MADI (49-56) (RME MADIface USB), MME (2 in, 0 out)
   8 MADI (1-8) (RME MADIface USB), MME (2 in, 0 out)
   9 MADI (9-16) (RME MADIface USB), MME (2 in, 0 out)
  10 Rec. Playback (IDT High Definit, MME (2 in, 0 out)
  11 Dock Mic (IDT High Definition A, MME (2 in, 0 out)
  12 MADI (41-48) (RME MADIface USB), MME (2 in, 0 out)
  13 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
< 14 Speakers / Headphones (IDT High, MME (0 in, 2 out)
  15 Communications Headphones (IDT , MME (0 in, 2 out)
  16 MADI (49-56) (RME MADIface USB), MME (0 in, 2 out)
  17 MADI (17-24) (RME MADIface USB), MME (0 in, 2 out)
  18 MADI (41-48) (RME MADIface USB), MME (0 in, 2 out)
  19 MADI (1-8) (RME MADIface USB), MME (0 in, 2 out)
  20 MADI (25-32) (RME MADIface USB), MME (0 in, 2 out)
  21 MADI (57-64) (RME MADIface USB), MME (0 in, 2 out)
  22 MADI (33-40) (RME MADIface USB), MME (0 in, 2 out)
  23 MADI (9-16) (RME MADIface USB), MME (0 in, 2 out)

while with asio support I can use the interface as one interface and not as different stereo interfaces...

@davrandom davrandom reopened this Jul 22, 2016
@davrandom
Copy link
Author

ufff... my mistake, I pressed "close and comment" instead of comment... I'd better get some rest today.

@mgeier
Copy link
Member

mgeier commented Apr 28, 2017

In Windows MME there seems to be a setting paWinMmeUseMultipleDevices and PaWinMmeStreamInfo::devices (see also PaWinMmeDeviceAndChannelCount).

None of this is currently implemented in the sounddevice module, but if somebody needs that, please speak up!

@marinasaizalia
Copy link

Hello,

I am exactly trying to do the same. I use RME fireface 802 sound card and Windows but would like to communicate using sounddevice or similar in Python. I need to simultaneously output to two different devices and record from another one. Did you find any solution for this problem or have any recommendation for me?

Thanks!

@mgeier
Copy link
Member

mgeier commented Jun 14, 2017

@marinasaizalia Did you have a look at the MME stuff I mentioned above?

On Linux/ALSA you can combine devices using a configuration file (.asoundrc), on macOS you can do the same thing with the "Audio MIDI Setup" (look for "Create Aggregate Device").
I'm sorry, but I have no clue if anything like that is possible with Windows.

@mgeier
Copy link
Member

mgeier commented Jun 14, 2017

@marinasaizalia With "two different devices" do you mean your RME fireface 802 plus another sound card?
Or do you mean two "pseudo devices" that are shown by PortAudio that are in reality both part of one and the same RME sound card?

In the latter case, you can just use ASIO and the sound card will be shown as one single device.
Are you using an ASIO driver?
This probably also is the case with WDM/KS? (UPDATE: it turns out not to be)

What does sd.query_devices() show?

@marinasaizalia
Copy link

@mgeier thanks for all these! With "two different devices" I mean just the RME fireface soundcard that has connected different inputs and outputs. I have to play in two (through two different set of earphones) and record simultaneously from a microphone. I call them device because when I do sd.play() I select the earphones I want to play through as device=its ID number.

So I guess I can use and ASIO driver. I may be missing this.

I am not in the same computer now so I cant show you the screenshot of sd.query_devices() but it shows a list of the inputs/outputs that are connected to the RME fireface soundcard plus the speakers in the computer. I can see different audio APIs: MME, WASAPI, WDM/KS and DirectSound but no ASIO. So when I tried to use sd.AsioSettings(channel_selectors=...) (https://python-sounddevice.readthedocs.io/en/0.3.7/) to create specific input/output settings I got an error which said "error opening output stream: incompatible host API stream info"

I only installed the driver for the RME soundcard. Do I also need an ASIO driver?

Thanks for everything (as you can see I am very new in all these!)

@marinasaizalia
Copy link

marinasaizalia commented Jun 14, 2017

@mgeier hello again! I went to the computer and got the sd.query_devices() so I copy it here to you. However, I just thought I am going to change the operating system to linux anyway.

sd.query_devices()
Out[2]: 
   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 ADAT 1 (1+2) (RME Fireface 802), MME (2 in, 0 out)
   2 Analog (7+8) (RME Fireface 802), MME (2 in, 0 out)
   3 AES (RME Fireface 802), MME (2 in, 0 out)
   4 Analog (5+6) (RME Fireface 802), MME (2 in, 0 out)
   5 Analog (11+12) (RME Fireface 80, MME (2 in, 0 out)
   6 Analog (9+10) (RME Fireface 802, MME (2 in, 0 out)
   7 Analog (1+2) (RME Fireface 802), MME (2 in, 0 out)
   8 Analog (3+4) (RME Fireface 802), MME (2 in, 0 out)
   9 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
< 10 Speakers (High Definition Audio, MME (0 in, 2 out)
  11 Analog (3+4) (RME Fireface 802), MME (0 in, 2 out)
  12 Analog (11+12) (RME Fireface 80, MME (0 in, 2 out)
  13 Analog (5+6) (RME Fireface 802), MME (0 in, 2 out)
  14 Analog (7+8) (RME Fireface 802), MME (0 in, 2 out)
  15 AES (RME Fireface 802), MME (0 in, 2 out)
  16 Speakers (RME Fireface 802), MME (0 in, 2 out)
  17 ADAT 1 (1+2) (RME Fireface 802), MME (0 in, 2 out)
  18 Analog (9+10) (RME Fireface 802, MME (0 in, 2 out)
  19 Primary Sound Capture Driver, Windows DirectSound (2 in, 0 out)
  20 ADAT 1 (1+2) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  21 Analog (7+8) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  22 AES (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  23 Analog (5+6) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  24 Analog (11+12) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  25 Analog (9+10) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  26 Analog (1+2) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  27 Analog (3+4) (RME Fireface 802), Windows DirectSound (2 in, 0 out)
  28 Primary Sound Driver, Windows DirectSound (0 in, 2 out)
  29 Speakers (High Definition Audio Device), Windows DirectSound (0 in, 2 out)
  30 Analog (3+4) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  31 Analog (11+12) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  32 Analog (5+6) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  33 Analog (7+8) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  34 AES (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  35 Speakers (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  36 ADAT 1 (1+2) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  37 Analog (9+10) (RME Fireface 802), Windows DirectSound (0 in, 2 out)
  38 ASIO Fireface USB, ASIO (22 in, 22 out)
  39 Speakers (High Definition Audio Device), Windows WASAPI (0 in, 2 out)
  40 Analog (3+4) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  41 Analog (11+12) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  42 Analog (5+6) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  43 Analog (7+8) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  44 AES (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  45 Speakers (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  46 ADAT 1 (1+2) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  47 Analog (9+10) (RME Fireface 802), Windows WASAPI (0 in, 2 out)
  48 Analog (7+8) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  49 AES (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  50 Analog (5+6) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  51 Analog (11+12) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  52 Analog (9+10) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  53 Analog (1+2) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  54 Analog (3+4) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  55 ADAT 1 (1+2) (RME Fireface 802), Windows WASAPI (2 in, 0 out)
  56 Speakers (HD Audio Speaker), Windows WDM-KS (0 in, 2 out)
  57 Analog (1+2) (Fireface Analog (1+2)), Windows WDM-KS (0 in, 8 out)
  58 Analog (1+2) (Fireface Analog (1+2)), Windows WDM-KS (2 in, 0 out)
  59 Analog (3+4) (Fireface Analog (3+4)), Windows WDM-KS (0 in, 2 out)
  60 Analog (3+4) (Fireface Analog (3+4)), Windows WDM-KS (2 in, 0 out)
  61 Analog (5+6) (Fireface Analog (5+6)), Windows WDM-KS (0 in, 2 out)
  62 Analog (5+6) (Fireface Analog (5+6)), Windows WDM-KS (2 in, 0 out)
  63 Analog (7+8) (Fireface Analog (7+8)), Windows WDM-KS (0 in, 2 out)
  64 Analog (7+8) (Fireface Analog (7+8)), Windows WDM-KS (2 in, 0 out)
  65 Analog (9+10) (Fireface Analog (9+10)), Windows WDM-KS (0 in, 2 out)
  66 Analog (9+10) (Fireface Analog (9+10)), Windows WDM-KS (2 in, 0 out)
  67 Analog (11+12) (Fireface Analog (11+12)), Windows WDM-KS (0 in, 2 out)
  68 Analog (11+12) (Fireface Analog (11+12)), Windows WDM-KS (2 in, 0 out)
  69 AES (Fireface AES), Windows WDM-KS (0 in, 2 out)
  70 AES (Fireface AES), Windows WDM-KS (2 in, 0 out)
  71 ADAT 1 (1+2) (Fireface ADAT 1 (1+2)), Windows WDM-KS (0 in, 2 out)
  72 ADAT 1 (1+2) (Fireface ADAT 1 (1+2)), Windows WDM-KS (2 in, 0 out)

@tgarc
Copy link
Contributor

tgarc commented Jun 14, 2017

@marinasaizalia I believe you want to use this one:

38 ASIO Fireface USB, ASIO (22 in, 22 out)

@marinasaizalia
Copy link

@tgarc you are right! i didnt even see that before. thanks!

@alfredwidell
Copy link

I have a related problem. In simultaneous playback/record I want to use one ASIO soundcard for input and another ASIO sound card for output or alternatively one of the other Windows API's for input soundcard and the ASIO API for the output soundcard. I need the output to be ASIO because I need flexibility to chose several output channels. When I try to choose two ASIO devices I get the "error opening output stream: incompatible host API stream info". Is what I'm trying to do at all possible?

@mgeier
Copy link
Member

mgeier commented Jul 27, 2017

It should work in general, but there may be a limitation imposed by ASIO.
Does it work with two different non-ASIO devices?

@alfredwidell
Copy link

I'm not sure if it works on 2 non-ASIO devices, I will have to check. Maybe it is a limitation with ASIO as you say.

@filterman
Copy link

filterman commented Aug 6, 2017

On linux i can use two different devices

import sounddevice as sd

def callback(indata, outdata, frames, time, status):
    outdata[:] = indata

with sd.Stream(device=('hw:0,1', 'hw:1,0'), samplerate=(48000, 48000), blocksize=1024, dtype=('int16', 'int16'), latency=None, channels=2):
    input()

this is Wire.py simplified example. hw:0,1 input and hw:1,0 ouput.

@bactone
Copy link

bactone commented Aug 27, 2019

@davrandom this post gives me a lot help, I also ignored the ASIO driver in the list. BTW, could you share an example of how to specify the corresponding ASIO channel(device), sample rate,blocksize and other parameters, so that the sound can be played though a certain ASIO output channel and recorded by another input one?

@chirico85
Copy link

Hi guys,

I had a similar problem as @marinasaizalia and want to share my experience with you. Hope that helps some of you.

I found out that during installation of ASIO4ALL the option "offline settings" was not available and instead some other, for me rubbish text, was displayed as the last option to check. Therefore, I could not see how and change from 4 pseudo devices going from my fireface 802 via adat1 passing a behringer device to 8 speakers. However, after making the changes within the asio4all settings, i.e. selecting adat1 (1+2), adat1 (3+4), adat1 (5+6) and adat1 (7+8), I could not see any change in the output with sd.query_devices(). No ASIO device showed up as expected. Out of nowhere, the output changed! Do not ask how... May be it is important (I think the manual indicates that) that no other process which uses ASIO should run parallely. I had spyder running and the conda prompt. It is still strange that matlab showed me the new device immediately even though other processes were running in the background.. I cannot explain what happened.

I did not make any changes in the sounddevice ASIO settings.

However, I expected according to @marinasaizalia experience to be the output something similar to

38 ASIO Fireface USB, ASIO (22 in, 22 out)

Instead I got

36 Analog (1+2), WDM/KS (0 in, 8 out)

I got confused because of the "Analog", the "(1+2)" and the "WDM/KS" . A lot to be confused about.. at least for me : )

I got the system running by routing in totalmix Analog (1+2), Analog (3+4), Analog (5+6) and Analog (7+8) to adat1 (1+2), adat1 (3+4), adat1 (5+6) and adat1 (7+8).
I don't know if that is the best solution. After a little research I found out that "WDM/KS" is in some points similar to ASIO. But if you ask me about details about it I am lost.

Cheers!

@mgeier mgeier changed the title selecting multiple devices as in and/or out selecting multiple devices as in and/or out (Windows) Oct 12, 2020
@chirico85
Copy link

I found the solution for my case in some other thread. I think it was here #137

uninstall sounddevice and portaudio with conda and reinstall with pip. sd.query_devices() displays ASIO now.

@SoulProficiency
Copy link

@marinasaizalia hello my friend,could u share us the example of how u slove your problems?i also want to use sounddevice to playback some audios and i don't know how to choose the channels(different loudspeaker,i think),thanks a lot!

@iamjonny
Copy link

I'm not sure if my usecase is different.

I've spent a few hours reviewing this now... trying to create aggregate device on windows.
I went for flexasio, and asked there also

I then had a look at Synchronous Audio Router, and used asioconfig to spawn the ASIO.CPL

I know (from testing) that on windows 11 I can use both my speakers and headphones at same time...

I'd like to try and create an aggregate (output) device, so apps using it and directing sound to pin1 sends to headphones,
and pin2 to speakers.

Even with VAC this doesn't look seem possible!

Am I overcomplicating, or trying to achieve the seemingly impossible?

A workaround may be to use a cli_tool like nircmd to dynamically target the device, but I'd love to see if it's possible to use pins-as-devices on a virtual aggregate device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants