pymumble
pymumble copied to clipboard
receive audio from multiple users and send at same time
Hi, I'm working with pymumble to communicate with a various number of users who also are using pymumble.
So it's not only sending audio (microphone) to murmur-server but also receiving audio from different users via pymumble and outputting that to a speaker.
At the moment I'm asking for all online users in an endless while-loop and adding the soundchunk of every user by using audioop.add.
When done for every user, the PCM-chunk will be written to speaker. As I notice that works but seems to have really bad performance when increasing number of speaking users at the same time. I would like to record a whole channel with more than 20 users, which seems to be impossible with that method.
Do you have alternative, better options to "mix" the sound of all users together and bring it to speaker with low latency?
Thanks for any help! :-)
Hi,
Can you put the part of the bot you use for the user voice parsing ?
I suppose you use the callback PYMUMBLE_CLBK_SOUNDRECEIVED function.
Maybe you will have better performance with a loop to receive the sound of all users : https://github.com/azlux/pymumble/blob/pymumble_py3/API.md#soundqueue-object-accessible-through-usersound
Sound is not merge together, but this function have buffer waiting for some loop to take the sound data, maybe it will help.
To be honest, I've never used it with more than 6 users.
Thanks for your answer, @azlux ! No, I don't use the Callback. How does the Callback work with more than one user? Will it merge all users together by itself? Didn't understand that function yet.
At the moment my implementation works in a sound_receive-function which runs endless in a thread. https://pastebin.com/2Ba6rcbe
In fact, the callback will be trigger user by user. So you also need to merge the sound manually (https://github.com/azlux/pymumble/blob/9de35a56f177aa179caa9ae0152241369e9ce282/pymumble_py3/mumble.py#L519) Using a callback isn't better, there are a little bit less calculation to do on the library side, but I think your bottleneck is to merge and send the audio to the speaker ?
Yes, I guess that's the bottleneck. It seems that every new user in the system is increasing the CPU usage pretty much.
Could it be a problem that I'm using the threading module to handle GUI, transmitting and receiving audio at the same time or shouldn't there be any connection with that method? Generally, is there any example implementation of using pymumble in receiving and transmitting mode simultaneously?
Sorry I don't have example. You can use a profiler library to find the bottleneck of your code ( example ) Using a thread to manage input and output separately in the same time is also a good idea.
Do you have any news about the tests ?