0

I am currently working on a script that should be able to output 8 channels of audio (.wav files) to 8 different channels on a soundcard. My script is sort of working, but I have syncronization issues. I am able to hear that the timing between the channels changes during playback, which is very critical.

Currently I am using threads to start each channel of sound.

My question is, if you guys have any suggestions to how I can achieve a better synchronization between channels/threads? I would still like to use sounddevice since it works well when mapping (left or right channel) my output channels.

Thank you all in advance.

1 Answers1

1

It's very hard (most likely impossible) to synchronize different streams. You should use only one Stream (or OutputStream) object at a time. Handling 8 channels in a single stream shouldn't be a problem.

You can use the play() function with 8 channels, or you can create a custom callback function that handles your 8 channels, and use it in a Stream or OutputStream.

UPDATE:

It is not possible to use multiple devices in a stream, see also issue 29 on Github. You can try using a different host API. Do you have an ASIO driver for your sound card? With ASIO you typically get one device with multiple channels. If that doesn't work, you can try to ask on the PortAudio mailing list.

The input data should be a 2-dimensional NumPy array with one column per channel. Have a look at the documentation of the callback parameter of the Stream class.

Matthias
  • 4,524
  • 2
  • 31
  • 50
  • Thanks for sharing your experiences. I had the feeling that using 8 different streams was not optimal. However, my soundcard (Behringer FCA1616) is installed as 4 different output stereo channels. At the moment I am trying to use OutputStream instead. Would you say, that using a buffer based system with the Stream option is better? – Christian Suhr Jøns Oct 10 '16 at 06:51
  • One more question: In the documentation for sounddevice, I cannot find out on what format the input data should be for a Stream? A matrix containing an interleaved channel on each row? – Christian Suhr Jøns Oct 10 '16 at 09:04
  • And when I have to output to several devices it should be device=1,2,3,4? – Christian Suhr Jøns Oct 10 '16 at 09:28
  • Thanks again for your time and experience. It helped me clarify what possibilities I have. – Christian Suhr Jøns Oct 11 '16 at 13:13