On Thursday 28 January 2010, at 21.01.38, David McClanahan
This has nothing to do with the definition of hard realtime. These lowlatency
kernels don't even claim to be *hard* realtime. I think you'd get "lowlatency"
or possibly "firm realtime", depending on who you ask.
True hard realtime systems don't really exist, but if we accept hardware
failure and application bugs as acceptable reasons for failure, we can get
pretty close. For Linux, you'd go with RTAI or RT-Linux.
However, although running all realtime audio code under RTAI or RT-Linux might
offer a slightly lower risk of drop-outs, those are pretty harsh environments,
even compared to the "strict" requirements of JACK clients, realtime safe
LADSPA or LV2 plugins and the like. You basically cannot use ANY syscalls, but
have to work with a completely different API. (RTAI/LXRT does allow hard
realtime code to run in userspace, but when a thread is actually running in
hard realtime context, it will be thrown back to "standard" mode as soon as it
makes an ordinary syscall.)
More seriously, you cannot make use of ANY normal Linux drivers. Drivers have
to be ported, so that all code involved in the hard realtime "loop" actually
runs under the realtime kernel, and not Linux.
Even more seriously, there is just no way that any realtime kernel can ensure
anything on bad hardware. If BIOS super-NMIs are blocking normal IRQs every
now and then, or you have some device + driver combo that abuses PCI bus
blocking (common issue with 3D accelerators), you may get worst case latencies
of any number of milliseconds - and there is nothing at all that any OS can do
about this. You *may* be able to avoid these issues by replacing cards,
patching or reconfiguring drivers or tweaking the BIOS settings, but as
general purpose PC/workstation hardware isn't really designed for this sort of
work, there are no guarantees. It basically comes down to trying hardware
until you find something that does the job.
BTW, this has very little to do with raw performance. A faster CPU does let
you finish the job quicker, but if you wake up too late, you still won't be
able to make the deadline...
The bottom line is that, in the context of mainstream hardware and systems
that aren't specifically put together for lowlatency audio work, this is a
matter of diminishing returns. Indeed, it's possible to do better than a
lowlatency kernel, but it's a lot of work, and it's completely wasted without
perfectly configured, well behaved hardware. Sure, RTAI or RT-Linux would
support 0.1 ms audio latency on a purpose built system with ported drivers,
properly configured BIOS, SMI hacks etc, but it just won't happen on your
> > Now, in real life, the "every time" part will never be quite accurate.
Well, yes - but going beyond lowlatency kernels, it's usually the hardware you
need to deal with; not the OS...
> > Of course, there's a big difference between a DAW that drops out a few
Same difference. If you have sufficiently solid scheduling for the realtime
processing part, you can build pretty much anything around that.
It's not about sophistication. A low cost singleboard computer with an AMD
Geode, VIA C7, some Intel Celeron or whatever you need in terms of raw power,
will do just fine - as long as the chipset, BIOS and connected devices are
well behaved and properly configured.
If you, as a manufacturer of synths or similar devices, don't want to try a
bunch of different motherboards for every new revision you make, you might
decide to design your own board instead. Then again, if your product is low
volume and requires enormous CPU power, carefully selected mainstream hardware
may still be a better option.
> The PC may be such a
SMI is one of them. In my experience, nearly every motherboard at least has
some BIOS features you must stay away from, so even "know good" hardware
sometimes need special tuning for this sort of work. General purpose computers
just aren't built for low latency realtime work - but most of them can still
do it pretty well, with some tweaking.
That's just pointless, as the ADC and DAC latencies are already several sample
periods, and the way DMA works on any PCI, USB or 1394 soundcard will add
somewhere around 64 bytes' worth of latency or more to that.
Also note that your average MIDI synth has anywhere from a few through several
tens of milliseconds of latency! You can only send around 1000 messages per
second over a standard MIDI wire anyway, so where would you get the timing
information to make use of less than 1 ms latency? Actually, going below a few
ms only guarantees that the notes in a chord can never be triggered
For knobs and similar "analog" controls, I'd say it takes at least tens of ms
before you start to notice any latency. For keys, I personally think it starts
to feel weird if the latency approaches 10 ms.
More importantly though, latency must be *constant*! A synth that just grabs
all pending events once per buffer cycle won't be playable with more than a
few ms of latency, as the "random" response times quickly become very
noticeable and annoying as the "average" latency increases. If incoming events
are properly timestamped and scheduled, this is much less of an issue, and
latency has the same effect as varying the distance to the monitor speakers.
//David Olofson - Developer, Artist, Open Source Advocate
.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://olofson.net http://kobodeluxe.com http://audiality.org |
| http://eel.olofson.net http://zeespace.net http://reologica.se |
Linux-audio-dev mailing list