python-sounddevice icon indicating copy to clipboard operation
python-sounddevice copied to clipboard

Question: Multiple devices

Open StuartIanNaylor opened this issue 4 years ago • 1 comments

Hi I have 3 input devices like so in my asound.conf I have worked out how to do a singular callback but puzzled how to do three. Do you aggregate the devices and then separate as tracks or can you have 3 device callbacks? If anyone has a code snippet for dummies please post.

pcm.cap1 {
  type plug
  slave {
    pcm "plughw:2,0"
    }
}

pcm.cap2 {
  type plug
  slave {
    pcm "plughw:3,0"
    }
}

pcm.cap3 {
  type plug
  slave {
    pcm "plughw:4,0"
    }
}

StuartIanNaylor avatar Mar 19 '21 15:03 StuartIanNaylor

You can create 3 streams with 3 separate callbacks. But note that those callbacks are not necessarily synchronized between each other.

You should also be able to create an aggregate device in the ALSA config, where all channels are available in a single stream with a single callback function.

mgeier avatar Mar 23 '21 11:03 mgeier

are there any ways to run two sound-cards without having to make hard configs in the OS? ie. doing it runtime to make it more cross-platform friendly.

seems like pulseaudio can do it

raveslave avatar Dec 09 '22 00:12 raveslave

@raveslave

are there any ways to run two sound-cards without having to make hard configs in the OS?

Not in a platform-independent way.

You can try to create separate streams for separate sound cards. But apart from not being synchronized, this only works on some platforms and is not guaranteed to work by PortAudio.

mgeier avatar Dec 18 '22 09:12 mgeier