Multichannel sound syncronization issues in Python (Sounddevice)

爷,独闯天下 提交于 2019-12-25 08:13:58

问题


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:


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.



来源:https://stackoverflow.com/questions/39894359/multichannel-sound-syncronization-issues-in-python-sounddevice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!