I’m using first-in-first-out queues to delegate voice creation, among other things – there is a daemon process listening for commands, and if it gets (for example) a play message, it adds the message (and params) to a queue, and another thread waits for messages in the queue, spawning voices for playback when it gets play messages.
I’ve been prototyping using the queue.Queue implementation from the python standard library along with threads from the threading module and spawning voices with a ProcessPool from the concurrent futures library, but that creates a lot of overhead for voice creation – in some cases I was seeing more overhead on voice management than DSP…
So I’m moving the voice management logic into cython, which lets me release the GIL and use real posix threads, as well as openmp’s parallel for loops – the catch is that I can’t use python objects in those contexts, including the standard library queues…
I’ll share my implementation when I’m further along!