Lowest possible latency

Moderator: flatmax

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Lowest possible latency

Post by robiwan » Thu Jul 06, 2017 12:56 am

I've tried finding the latency of the WM8731 codec, but there's no specific information on this in the datasheet. I suspect it to be low though, on the order of < 0.5 ms.

I've bought the soundcard in order to make a system with as low a latency as can be achieved. I suspect a 32 sample ALSA period size (~ 0.7 ms @ 48Khz) should be achievable on a R Pi 3 ?

Any feelings/thoughts on this ?

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Thu Jul 06, 2017 4:40 pm

To clarify, I'm seeking to minimize the latency of the audiopath:

ADC -> ALSA -> DAC

:)

flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Re: Lowest possible latency

Post by flatmax » Thu Jul 06, 2017 5:44 pm

I have run the ALSA utility latency to find it is of the order of 500 us (half a microsecond). This was found using very low CPU load.

Check here for example :
https://www.kickstarter.com/projects/12 ... ts/1606640

I would start with 2 periods of 1ms and see if that works nicely. If so, then reduce the sample count accordingly.

Can you post your findings back here please ?

thanks
Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Thu Jul 06, 2017 7:35 pm

Thanks! Will do so.

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Wed Jul 12, 2017 5:02 pm

Ok, I've setup my Pi with the stereo board (and have been streaming Spotify via Mopidy, sounds really good! :) )

Anyway, built the ALSA latency test and got following results:
./latency -r 96000 -f S32_LE -p
Maximum read: 56 frames
Maximum read latency: 583.333us, 0.583333ms (1714.2857Hz)
Playback time = 131878.455664, Record time = 131878.455662, diff = 2

./latency -r 48000 -f S32_LE -p
Maximum read: 48 frames
Maximum read latency: 1000.000us, 1.000000ms (1000.0000Hz)
Playback time = 132038.521231, Record time = 132038.521228, diff = 3

Not bad at all. The application I have in mind will do a lot of FFT convolution, so that's an aspect also, to have enough time to compute everything during a callback period.

flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Re: Lowest possible latency

Post by flatmax » Wed Jul 12, 2017 6:18 pm

OK - sounds like you have a real time application on your hands.

How many Fourier bins are you targeting ?
I find that the more Fourier bins I use, the lower the latency requirement.

Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Wed Jul 12, 2017 6:29 pm

Depends, I'm doing FIR filters in the frequency domain, so it can be 4 instances with lengths of up to 0.5 s (24000 taps @48K). I'm planning on a partitioned implementation to remove the latency due to FFTs. Maybe dual-rate to lower the lengths of the IRs. I'll see how it goes. Also, it is possible to use the GPU for the FFTs, which should heighten performance significantly.

flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Re: Lowest possible latency

Post by flatmax » Wed Jul 12, 2017 6:39 pm

Oh be interested to hear if you get GPU computation for DFTs going !

Sounds like you have nice long filters. Are you running FIR eqs or a different application ?
You writing the software yourself ?

Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Wed Jul 12, 2017 7:49 pm

It is for a room correction application, so 0.3 to 0.5 s length of FIRs usually are adequate, and yes, I'll be writing the software myself. Right now I'm trying to determine where to apply the processing. Since I want to do both in/out low latency and be able to stream audio (like Spotify), I think an ALSA PCM plugin would be the appropriate place.

flatmax
Posts: 604
Joined: Sat Jul 23, 2016 11:39 pm

Re: Lowest possible latency

Post by flatmax » Wed Jul 12, 2017 7:54 pm

Room correction - nice one.

I agree, an ALSA plugin would probably be the best. That way you can set it to be default and not even have to think about it.

I have an ALSA Plugin class as part of gtkiostream. An example is here :
http://gtkiostream.flatmax.org/ALSAExte ... ample.html

You can also interface Eigen matrices to that, which come with an fftw inferface. You may find that useful.

Are you planning to use C/C++ ?

Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests