Re: real-time threaded IO with low latency (audio)

Ove Ewerlid (Ove.Ewerlid@syscon.uu.se)
Sat, 24 Jul 1999 16:28:48 +0200


Paul Barton-Davis wrote:
>
> >> a "real" FX processor can do real-time flanging with a 0.2ms
> >> delay. the idea that linux (or beos) for that matter can step into
> >> this kind of role is absurd, or close to it.
> >
> >Absurd? My greatest problem seems to be the PCI DMA burst size of the
> >card I'm using now.
>
> At a 48KHz sample rate, a 0.2ms flange is slightly under 10
> samples. If you specify a fragment size of 16 (just for the power-of-2
> fan club), that translates to 4800 interrupts a second from the
> soundcard just to say "i crossed a fragment boundary". I didn't see
> any posts to linux-kernel that really answered the question "how many
> cycles are burnt handling a timer interrupt", but I have a pretty good
> feeling that Linux wasn't meant to run well with a regular 4.8KHz
> interrupt rate from something requiring an interrupt handler as
> relatively complex as the typical DAC handler.

You must be missing something here!
Flanging with a intersignal delay from 1 sample and up should be no
problem to deal with under linux. Just make sure that the total delay
of the signal is higher then the longest intersignal delay.
Interrupt rate or fragment size has nothing to do with this!
You may need to have an overal delay as a multiple of the fragment size.

> Yes, but thats not a realistic example of what an FX unit does. You've
> got to copy data from the DAC output buffer into the host memory and
> back again. Believing that you can do this *and* the FX computation
> *and* run other things seems wrong to me.

This seems perfectly right to me!
Setting up the sound card to run in circular mode and then MMAPing
the DMA buffer into user space allows for very close operation to
the hardware limits in terms of delays. The notion of fragments
is not relevant in the case of MMAP - the user level process gets
full control. It can, using tricks, easily phase lock on the DMA
input buffer. The DMA output buffer can then easily be driven.
If you have an SMP system these techniques are very useful!

Really, if you play with HIFI-sound you want to be as close as possible
to the hardware. Normal interfaces (write/read) does not allow close
enough
under linux so then use other interfaces, like mmap, that was designed
to get close to the hardware.

Ove

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/