The previous log outlined some concerns with microphone handling delays caused by delays when the loop yields to the uasyncio scheduler (e.g. the measure delay of 6ms). I explored the use of an alternative uasyncio library called Fast IO. The Fast IO library adds a high-priority I/O queue to uasyncio. This allows a coroutine to be given higher priority than other coroutines that are waiting to run.
I changed the microphone coroutine to use this high-priority queue and ran some performance tests. The change was done in one line - I used a high-priority millisecond timer in place of the the standard uasyncio sleep timer. Using this new timer results in the microphone loop getting scheduled in a high-priority queue -- the microphone loop will run before any of the other coroutines.
With this change the yield time in the microphone handling loop was reduced by about 20%. More importantly, the change insures that the time-critical microphone handling loop always gets priority over other waiting coroutines. This will greatly reduce the risk of overruns in the received DMA sample buffers.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.