26

I want to run Linux program that require a soundcard, on a server, which has no soundcard. Is it possible to create a dummy soundcard? I am totally unaware of Linux sound system internals. Please point me in right direction.

I have followed this example: http://alsa.opensrc.org/.asoundrc but it didn't work out.

PS: There is similar question: How to create a virtual sound device in Linux?. But this is totally different in the context that the user is creating an alias to already available soundcard.


Edit:
I want a dummy device to be created in /dev/.. so that any application that needs a sound device will find it.
I am completely unware, how alsa works. So I simply followed the example. I created /etc/asound.conf with:

pcm.card0 {
    type hw
    card 0
}
ctl.card0 {
    type hw
    card 0
}

And aplay -L gives me:

null
    Discard all samples (playback) or generate zero samples (capture)
3
  • Yes, there is such a thing as "dummy" sound device in Alsa. But you need to elaborate about what exactly "didn't work out" for you. Error message, not detected by the software, etc. Also, does the target "linux program" use ALSA at all? Because if it doesn't, messing with ALSA config files won't give you much.
    – haimg
    Oct 10, 2011 at 4:52
  • I want a virtual sound device to be created in /dev/...
    – ssapkota
    Oct 10, 2011 at 5:57
  • See the edit for more.
    – ssapkota
    Oct 10, 2011 at 6:08

3 Answers 3

17

You need to load a dummy sound driver. Please see the Alsa Wiki for detailed info, but here are the basics:

  1. Load the driver:

    modprobe snd-dummy ; modprobe snd-pcm-oss ; modprobe snd-mixer-oss ; modprobe snd-seq-oss

  2. Have proper .asoundrc file (you have it covered)

  3. Configure autoloading of the drivers. Add this to /etc/modules.conf:

    # OSS/Free portion - card #1
    alias sound-slot-0 snd-card-0
    alias sound-service-0-0 snd-mixer-oss
    alias sound-service-0-1 snd-seq-oss
    alias sound-service-0-3 snd-pcm-oss
    alias sound-service-0-8 snd-seq-oss
    alias sound-service-0-12 snd-pcm-oss

There are actually quite a few things involved, I suggest you visit the Wiki page above for more detailed explanation.

2
  • A question. Is possible to create a Linux kernel device driver that simulates a sound card to Linux then alsa, OSS, etc? I am reading Linux device and asking myself if it is possible.
    – deFreitas
    Oct 19, 2016 at 1:46
  • Core module for the sequencer seems to show as snd-seq-dummy now.
    – DBrown
    Dec 7, 2017 at 21:18
11

I too had issues with this when trying to get a Dummy Sound device working on the Raspberry Pi running Raspian (derivative of Debian). The Pi on has an audio output but no input, and I want to use an application that looks for both, even though I only need an output (PJSIP).

However, the info above did not work for me and neither did the WiKi page. After speaking with a user form the ALSA mailing list, they suggested that the info on the WikI page is out of date, however, they gave me pointers as to how to solve this.

Firstly, I only need to load the 'snd-dummy' module using:

sudo modprobe snd-dummy

However, the device does not stay present after a reboot. On the Pi, this module can be loaded via the '/etc/modules' file, editing this file to load the driver produced the desired results:

sudo nano /etc/modules

My /etc/modules file simply looks like this:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
snd-dummy

So, the default driver loads first, then the Dummy driver load second. Job done!

Good Luck

Chris

2
  • @logoff do you think would work in a docker container as well as on the rasberry pi?
    – thataustin
    Feb 17, 2017 at 3:22
  • @thataustin I guess you need to give access to hardware to the Docker container. I suggest try it first without Docker, and if you succeed, try with Docker.
    – logoff
    Feb 22, 2017 at 18:08
0

I do also use it for Linphone on RaspberryPi, as it requires an input device, however I had to add fake_buffer=0 param, else the dummy capture device would grab lots of random noise, and that would be weird... you can do it like:

sudo modprobe snd-dummy fake_buffer=0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .