xmos / lib_src

Sample rate conversion library
Other
16 stars 18 forks source link

Update ASRC task to dynamically set FIFO length to improve latency #133

Open ed-xmos opened 3 weeks ago

ed-xmos commented 3 weeks ago

Currently all SRs in and out use the same FIFO length. This means it needs to be sized for the worst case and consequently causes higher than needed latencies at lower output rates. Currently it gets sized by the app and passed in as a constant:

https://github.com/xmos/lib_src/blob/71ae31b41385a7b26a803f253b441fe0044fbcac/lib_src/src/asrc_task/asrc_task.c#L411

We now have the figures (and equation) of how large it should be this could be optimised depending on SR to improve low rate group delay by quite a lot (35% or better).

ed-xmos commented 3 weeks ago

Having thought about this, I think passing in an array of n FIFO lengths (one for each output rate) to ASRC task would make sense. If passed as NULL it could just use MAX_FIFO_LEN for all.

This way the user could optimise the lengths as required based on their PPM and SR needs.

However this is a breaking API change so would need a bump in major version unless it could be added to https://github.com/xmos/lib_src/blob/71ae31b41385a7b26a803f253b441fe0044fbcac/lib_src/src/asrc_task/asrc_task.h#L88C16-L88C30