DSPRelated.com
Forums

PC audio in-out latency.

Started by Jake Janovetz September 30, 2004
Hi folks-

Quick question for someone with experience in the area: What are
reasonable latencies for standard PCs and easily-available sound cards
when performing real-time filtering through the CPU?

Mostly, this gets to the buffering question and what size buffers are
typically applied to input/output buffers on Windows XP and Linux?  I
know there are low-latency patches for Linux.  What are the latencies
with/without these patches?

   Jake
Jake Janovetz wrote:
> > Hi folks- > > Quick question for someone with experience in the area: What are > reasonable latencies for standard PCs and easily-available sound cards > when performing real-time filtering through the CPU? > > Mostly, this gets to the buffering question and what size buffers are > typically applied to input/output buffers on Windows XP and Linux? I > know there are low-latency patches for Linux. What are the latencies > with/without these patches? > > Jake
Benno Senoner one of the developers of the Linux low latency patches is claiming latencies as low as 2.1ms : http://www.gardena.net/benno/linux/audio/ This is with the 2.4 kernel. The 2.6 kernel hasn't quite caught up to this low level of latency yet. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Seen on comp.lang.python: Q : If someone has the code in python for a buffer overflow, please post it. A : Python does not support buffer overflows, sorry.
Jake Janovetz wrote:

> Hi folks- > > Quick question for someone with experience in the area: What are > reasonable latencies for standard PCs and easily-available sound cards > when performing real-time filtering through the CPU? > > Mostly, this gets to the buffering question and what size buffers are > typically applied to input/output buffers on Windows XP and Linux? I > know there are low-latency patches for Linux. What are the latencies > with/without these patches?
Typical latency on Windows using DirectSound is 20ms.
> Jake
-- Phil Frisbie, Jr. Hawk Software http://www.hawksoft.com
"Phil Frisbie, Jr." <phil@hawksoft.com> wrote in message
news:Y7_6d.15765$54.240418@typhoon.sonic.net...
> Jake Janovetz wrote: > > > Hi folks- > > > > Quick question for someone with experience in the area: What are > > reasonable latencies for standard PCs and easily-available sound cards > > when performing real-time filtering through the CPU? > > > > Mostly, this gets to the buffering question and what size buffers are > > typically applied to input/output buffers on Windows XP and Linux? I > > know there are low-latency patches for Linux. What are the latencies > > with/without these patches? > > Typical latency on Windows using DirectSound is 20ms.
There are also other driver options for Windows such as ASIO which can achieve lower latencies. I'm not familiar with what is available for Linux.
On 2004-09-30 20:08:54 +0200, jakespambox@yahoo.com (Jake Janovetz) said:

> Hi folks- > > Quick question for someone with experience in the area: What are > reasonable latencies for standard PCs and easily-available sound cards > when performing real-time filtering through the CPU? > > Mostly, this gets to the buffering question and what size buffers are > typically applied to input/output buffers on Windows XP and Linux? I > know there are low-latency patches for Linux. What are the latencies > with/without these patches? > > Jake
Well, that depends on many many factors - the hardware used, drivers, system, system/kernel version, even on the sample rate and the number of channels the audio h/w needs to deal with (a buffer size of 512 samples has a different meaning depending on the above parameters). When you say real time filtering, does this imply pass-through (full duplex) processing? Or do you simply want to filter a signal that is stored on disk during playback? The latter usually has a lower latency (between changing the parameters and the effect becoming audible) while the former has both input and output latency that add up. Also, are you doing block-based processing (like performing an FFT every n samples) or continuous processing (ie. equal load per sample)? Required buffer sizes are usually higher for the former type to avoid spurious CPU overs and you might have a higher latency on the algorithm side due to the OLA bookkeeping. Also, what other processes are running on your system that might require higher audio buffer sizes to avoid overs (ie. processes with a high priority that might spuriously overload the system if the load is already high)? IOW: is the filtering using up much or all available CPU power, or just a few percent? I believe there is no general answer to your question without taking these things into account. If you do a straight playthrough you may be lucky and get latency down to a few ms. Usually, that figure is much higher, I'd say within one to several dozen ms for most Linuxes, and even higher for Windoze. -- Stephan M. Bernsee http://www.dspdimension.com
A few years ago, I wrote a Windows device driver filter for the 
www.SoundDevices.com  USBPre and spent quite a bit of time working with 
users and application developers on the latency subject.  In the Windows 
environment, there are several different APIs for getting sound in and out. 
These include Wave, DirectSound, ASIO(not MicroSoft) and Kernel Streaming 
(KS).

Wave and DirectSound use 10msec buffers and you'll end up with several 
buffers. 20-40 msec latency.
ASIO can achieve 4 msec (record and playback loop) see http://usb-audio.com/ 
ASIO drivers work in Windows but are not Microsoft.
Kernel Streaming (KS) is a method of using MicroSoft drivers at the device 
driver level.  This allows latencies similar to ASIO.

I wouldn't bother with the Wave API, it's pretty much legacy code.
DirectSound is convenient to use if the latency is acceptable.  You could 
implement the filter with a DirectX Media Object (DMO).
ASIO has low latency, but installs non-MicroSoft drivers for the audio 
devices and needs ASIO aware applications which can be a hassle.
Kernel Streaming has low latency, uses standard drivers but requires lower 
level programming.

I haven't looked at KS lately.  It may be possible to implement a DMO and 
use KS to reduce latency and maintaining the convenience of DirectX.



"Jon Harris" <goldentully@hotmail.com> wrote in message 
news:2s3a8nF1fuha4U1@uni-berlin.de...
> "Phil Frisbie, Jr." <phil@hawksoft.com> wrote in message > news:Y7_6d.15765$54.240418@typhoon.sonic.net... >> Jake Janovetz wrote: >> >> > Hi folks- >> > >> > Quick question for someone with experience in the area: What are >> > reasonable latencies for standard PCs and easily-available sound cards >> > when performing real-time filtering through the CPU? >> > >> > Mostly, this gets to the buffering question and what size buffers are >> > typically applied to input/output buffers on Windows XP and Linux? I >> > know there are low-latency patches for Linux. What are the latencies >> > with/without these patches? >> >> Typical latency on Windows using DirectSound is 20ms. > > There are also other driver options for Windows such as ASIO which can > achieve > lower latencies. I'm not familiar with what is available for Linux. > >
Search on Google for "ASIO4ALL".
It's a driver patch that greatly reduces non-ASIO
drivers latency.
Very impressive, really.
Gary G wrote:
> > Search on Google for "ASIO4ALL". > It's a driver patch that greatly reduces non-ASIO > drivers latency. > Very impressive, really.
The most implressively low latency I've seen is on MacOSX with JACK (Jack Audio Connect Kit): http://www.jackosx.com/ The people who ported JACK from Linux are claiming sub millisecond latency: http://www.linuxdj.com/audio/lad/contrib/zkm_meeting_2004/slides/sunday/stephane_letz-jack_macosx.pdf Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Moore's Law: hardware speed doubles every 18 months Gates' Law: software speed halves every 18 months
On 2004-10-07 22:51:35 +0200, Erik de Castro Lopo <nospam@mega-nerd.com> said:

> The most implressively low latency I've seen is on MacOSX > with JACK (Jack Audio Connect Kit): > > http://www.jackosx.com/ > > The people who ported JACK from Linux are claiming sub millisecond latency: > > http://www.linuxdj.com/audio/lad/contrib/zkm_meeting_2004/slides/sunday/stephane_letz-jack_macosx.pdf
Erik Hi
> > > Erik
Hi Erik, have you tested it? I'm asking because low latency usually implies playback glitches when the CPU load is high, so I am generally very sceptical about the actual value of such claims when it comes to the practical side of things... -- Stephan M. Bernsee http://www.dspdimension.com
"Stephan M. Bernsee" wrote:
> > Hi Erik, > > have you tested it? I'm asking because low latency usually implies > playback glitches when the CPU load is high, so I am generally very > sceptical about the actual value of such claims when it comes to the > practical side of things...
I haven't tested it myself. I don't have access to suitable hardware. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ The National Multiple Sclerosis Society of America recently started an advertising campaign with the slogan "MS: It's not a software company". Seasoned IT professionals will have no trouble telling the two MS's apart. One is a debilitating and surprisingly widespread affliction that renders the sufferer barely able to perform the simplest task. The other is a disease.