Description
I just thought it might be relevant to discuss an alternative implementation of low latency audio streaming I've been working towards.
The general idea can be explained in a few points:
- Audio callback is implemented in GIL-less C and does nothing but read and write data from and to a ring buffer (no processing)
- Python user communicates data to the audio callback via a cffi wrapped portaudio ring buffer.
- Audio processing is done using reader and writer threads. If low latency is not the highest priority, these can be implemented using python threads. Otherwise, they can be implemented using C or better yet, through Cython using
with nogil
.
My intention is to make a flexible architecture whose feature set can be extended relatively easily.
This is what I've been trying to achieve with this python module I've been working on: https://github.com/tgarc/pastream/tree/ringbuffer. Currently, I'm still using a few python threading synchronization primitives to synchronize with the audio callback since it made coding a bit simpler, but my intention is to move towards a scheme that doesn't require acquiring in the GIL in the callback.
Anyway, I just wanted to bounce these ideas off you and see if anything sticks :)