Independent ALSA and linux audio support site

Dsnoop

From the ALSA wiki

Jump to: navigation, search

dsnoop is the equivalent of the dmix plugin, but for recording sound. The dsnoop plugin allows several applications to record from the same device simultaneously.

\

Contents

The dsnoop howto

Default Alsa interface

By default, Alsa provides a dsnoop interface.

Is dsnoop available?

Normally, when using a recent system, dsnoop should be available. To list the available devices, enter:

arecord -L

Normally, dsnoop should be part of the available devices, and you should read a line including the following information:

dsnoop 'cards.pcm.dsnoop'

Recording from the default dsnoop interface

If dsnoop is here, let us use it. Plug a sound source (microphone, line-in) into your sound device, run amixer to select the correct input source and type:

arecord -f cd -c 2 -D dsnoop foobar.wav This will record from the dsnoop interface at CD quality level.

Writing a custom dsnoop interface

Basic syntax

The syntax is almost identical to the dmix plugin:

pcm.dsnooped {
    type dsnoop
    slave {
        pcm "hw:0,0" 
        channels 2 
    }
}

Choosing recording rates

You may also define custom recording rates:

pcm.dsnooped {
    type dsnoop
    slave {
        pcm "hw:0,0" 
        channels 2 
        period_size 1024
        buffer_size 4096
        rate 48000
        periods 0 
        period_time 0
    }
}

In this example, the sound is recorded at 48000 Hz.

If the soundcard does not support the requested rate, the sound is converted at software level.

Recording from left or right channel

It may be sometimes interesting to record (in mono) from left or right channel of a stereo sound.

For example, the Edirol UA-25 audio device has two mono microphones inputs, which are combined into a stereo (right/left) sound during recording. Whenever you record your voice using one mono microphone, the output is stereo, with a blanck channel being degraded by noise.

Some software may be able to transform the stereo sound into a mono sound, mixing the recorded voice (first channel) with noise (second channel), thus degrading sound quality.

Thanks to the dsnoop plugin, it is possible to overcome this problem.

Let us define two virtual dsnoop interfaces, for left and right channel:

pcm.record_left {
    type dsnoop
    ipc_key 234884
    slave {
        pcm "hw:0,0"
        channels 2
    }
    bindings.0  0
}
pcm.record_right {
    type dsnoop
    ipc_key 2241234
    slave {
        pcm "hw:0,0"
        channels 2
    }    
    bindings.0  1
} 

Now, you can record from the left channel using the following command:

 arecord -f cd -c 1 -D record_left foobar.wav

Your sound is now pure mono, not fake mono downmixed from a stereo sound.


See .asoundrc for docs and config examples for pcm plugins. Also see the alsa-lib page.

Retrieved from "http://alsa.opensrc.org/Dsnoop"

Category: ALSA plugins