Skip to contentSkip to conversation

DSnoop Latency

DISCUSSION Kenth Andersson 2 participants 4 messages Oct 7, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using a M-Audio Delta 44 sound card which is 4 mono channels. I'm using DSnoop
plugin to divide this 4 mono channels into two virtual sound cards, cline1-2, each with a stereo configuration.

My setup is as follows:
I got two live sound streams running, streaming sound over the network from cline1 I'm capturing 8000 mono s16_le sound
from cline2 I'm capturing 22050 stereo s16_le sound

I'm running this on a P4 3,2GHz HT Machine and it uses about 20% of CPU.

My problem is that there are BIG latency in the stereo stream, why is that? I understand that dsnoop has to do a sample rate conversion from input sample rate to both 8000 and 22050, but it looks like this conversion is very slow, without using all my CPU.

1. Anybody know anything about this, it it possible to prevent the latency?
2. Does anyone know of a better solution then dsnoop, that don't have this latency?

/Kenth

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#1 lore raw

At Fri, 7 Oct 2005 15:01:03 +0200,

Quoted 8 lines · Kenth Andersson

Hi,

I'm using a M-Audio Delta 44 sound card which is 4 mono channels. I'm using DSnoop
plugin to divide this 4 mono channels into two virtual sound cards, cline1-2, each with a stereo configuration.

Quoted 6 lines

My setup is as follows:
I got two live sound streams running, streaming sound over the network from cline1 I'm capturing 8000 mono s16_le sound
from cline2 I'm capturing 22050 stereo s16_le sound

I'm running this on a P4 3,2GHz HT Machine and it uses about 20% of CPU.

First of all: which ALSA version?

Quoted 2 lines

My problem is that there are BIG latency in the stereo stream, why is that?

How BIG do you mean? Any objective number, even approximately?

Quoted 4 lines

I understand that dsnoop
has to do a sample rate conversion from input sample rate to both 8000 and 22050, but it looks like this
conversion is very slow, without using all my CPU.

I don't think it's the conversion layer.
Or it might be the period-size misalignment problem. Try 24kHz on one side, for example (assuming that dmix slave is running on 48kHz).

Quoted 4 lines

1. Anybody know anything about this, it it possible to prevent the latency?
2. Does anyone know of a better solution then dsnoop, that don't have this latency?

You mixed up two things: CPU usage and the latency. In theory, both have nothing to do with each other.

The latecy of dsnoop depends on its configuration. Suppose you're using "dsnoop" PCM without extra setup, its period size is 1024 frames. This exactly defines the latency.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#2 lore raw

Hi,

I'll try to explain my problem more precise

Alsa version: 1.0.8

My problem is that if I set the sound card to 22050Hz and try to capture 10 seconds of sound (22050 * 10 samples). This would take precisely 10 seconds because it's realtime, but through dsnoop it takes more then 10 seconds, about 160 samples to long time if dsnoop is initialized to 8000 Hz and then tries to resample to 22050. This is a big problem then trying to capture live sound and stream it over network in realtime, because I can't get all the sound in realtime through dsnoop.

DSnoop settings:
rate 8000
period_size 1024
period_time 0
buffer_size 4096

The reason why i got rate 8000 Hz and capture at 22050 Hz it that I got another process doing the same thing at 8000Hz (at the same time). I read 1024 samples each time from dsnoop.

Does this explain my problem?

/Kenth

Quoted 50 lines · Takashi Iwai

At Fri, 7 Oct 2005 15:01:03 +0200,

Quoted 8 lines · Kenth Andersson

Hi,

I'm using a M-Audio Delta 44 sound card which is 4 mono channels. I'm using DSnoop
plugin to divide this 4 mono channels into two virtual sound cards, cline1-2, each with a stereo configuration.

Quoted 7 lines

My setup is as follows:
I got two live sound streams running, streaming sound over the network from cline1 I'm capturing 8000 mono s16_le sound
from cline2 I'm capturing 22050 stereo s16_le sound

I'm running this on a P4 3,2GHz HT Machine and it uses about 20% of CPU.

First of all: which ALSA version?

Quoted 3 lines

My problem is that there are BIG latency in the stereo stream, why is that?

How BIG do you mean? Any objective number, even approximately?

Quoted 5 lines

I understand that dsnoop
has to do a sample rate conversion from input sample rate to both 8000 and 22050, but it looks like this
conversion is very slow, without using all my CPU.

I don't think it's the conversion layer.
Or it might be the period-size misalignment problem. Try 24kHz on one side, for example (assuming that dmix slave is running on 48kHz).

Quoted 5 lines

1. Anybody know anything about this, it it possible to prevent the latency?
2. Does anyone know of a better solution then dsnoop, that don't have this latency?

You mixed up two things: CPU usage and the latency. In theory, both have nothing to do with each other.

Quoted 8 lines

The latecy of dsnoop depends on its configuration. Suppose you're using "dsnoop" PCM without extra setup, its period size is 1024 frames. This exactly defines the latency.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl

#3 lore raw

At Fri, 7 Oct 2005 15:51:46 +0200,

Quoted 6 lines · Kenth Andersson

Hi,

I'll try to explain my problem more precise

Alsa version: 1.0.8

Argh... too old version to debug...

Quoted 15 lines

My problem is that if I set the sound card to 22050Hz and try to capture 10 seconds of sound (22050 * 10 samples). This would take precisely 10 seconds because it's realtime, but through dsnoop it takes more then 10 seconds, about 160 samples to long time if dsnoop is initialized to 8000 Hz and then tries to resample to 22050. This is a big problem then trying to capture live sound and stream it over network in realtime, because I can't get all the sound in realtime through dsnoop.

DSnoop settings:
rate 8000
period_size 1024
period_time 0
buffer_size 4096

Quoted 5 lines

The reason why i got rate 8000 Hz and capture at 22050 Hz it that I got another process doing the same thing at 8000Hz (at the same time). I read 1024 samples each time from dsnoop.

Does this explain my problem?

Currently, the interrupt timing depends on the slave PCM. That's why you get inaccurate stop time.
Either increase the rate and/or decrease the period size. (The buffer size doesn't play any role here, BTW.)

Also, I don't think it's a good idea to resample from 8khz to 22.5kHz from the sound quality viewpoint at all...

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl