1
From: "Benno Senoner" <sbenno@gardena.net>
2
To: <music-dsp@shoko.calarts.edu>
3
Subject: Re: [music-dsp] coding realtime guitar efx on a "pc"
4
Date: Saturday, June 30, 2001 8:19 AM
8
you are solving your problem the wrong way:
9
you need to use a single threaded solution which does this:
11
- set the audio I/O parameters to fragnum=4 fragsize=128 bytes (=32samples) if
12
you use stereo or fragsize=64 bytes (=32 samples) if you use mono.
14
(do not forget to activate fulltuplex with using the _TRIGGER_ stuff)
15
(you need to frist deactivate audio and then start the trigger after the DAC is
16
prefilled (see below))
18
This will give you a total input to output latency of 4x32 samples
19
= 128 samples which at 44.1kHz correspond to 2.9msec latency.
21
now set your process to SCHED_FIFO (see man sched_setscheduler)
23
after the initialization your code should do more than less this:
25
- write() 4 x 32 samples to the audio fd in order to prefill the DAC.
26
Without this you will get dropouts.
29
read() 32 samples from ADC
30
perform_dsp_stuff() on the 32 samples
31
write() 32 samples to DAC
34
If you use a low latency kernel and pay attention to all the stuff above, then
35
you will get rock solid 3msec latencies (plus eventual converter latencies but
36
these are in the 1-2msec range AFAIK).
38
Using multiple threads , pipes etc, only complicates your life and often makes
39
it impossible to achieve these low latences.
41
Realtime/audio programming is not an easy task , this is why people often
42
fail to get the desired results even if their hardware is low-latency capable.
44
The problem is that the final latency depends on the hardware you use,
45
the application and the operating system.
50
http://www.linuxaudiodev.org The Home of Linux Audio Development
57
On Sat, 30 Jun 2001, you wrote:
58
> On 2001-06-29 21:38 +0200, Benno Senoner wrote:
60
> > OSS/Free refuses to use a low # of frags ?
66
> The fact is that ioctl(SNDCTL_DSP_SETFRAGMENT) succeeds with
67
> values as low a 0x10007 (one 128-B fragment) but the latency is
68
> still high enough to be clearly noticeable, which suggests that
69
> it's *way* above 2/3 ms. This is on an otherwise idle machine
70
> equipped with a SB PCI 128.
72
> But maybe it's me who's doing something wrong. I've been careful
73
> to flush stdio buffers or use unbuffered I/O (write(2)) but I
74
> may have let something else through.
76
> For example, since the signal processing and the I/O are done by
77
> two different vanilla processes communicating via pipes, it may
78
> be a scheduling granularity problem (E.G. the kernel giving the
79
> I/O process a time slice every 20 ms).
82
> Andr� Majorel <amajorel@teaser.fr>
83
> http://www.teaser.fr/~amajorel/
85
> dupswapdrop -- the music-dsp mailing list and website: subscription info,
86
> FAQ, source code archive, list archive, book reviews, dsp links
87
> http://shoko.calarts.edu/musicdsp/
91
dupswapdrop -- the music-dsp mailing list and website: subscription info,
92
FAQ, source code archive, list archive, book reviews, dsp links
93
http://shoko.calarts.edu/musicdsp/