How to create a virtual sound device in Linux?

Solution 1:

You will have to edit ALSA configuration files in order to achieve this, which unfortunately involves a significant amount of black magic.

Here's an example taken from the ALSA wiki showing how to split a card's front and rear stereo outputs into two independent audio devices:

pcm.dshare {
    type dmix
    ipc_key 2048
    slave {
        pcm "hw:0"
        rate 44100
        period_time 0
        period_size 1024
        buffer_size 8192
        channels 4
    }
    bindings {
        0 0
        1 1
        2 2
        3 3
    }
}
pcm.frontx {
    type plug
    slave {
        pcm "dshare"
        channels 4
    }
    ttable.0.0 1
    ttable.1.1 1
}
pcm.rearx {
    type plug
    slave {
        pcm "dshare"
        channels 4
    }
    ttable.0.2 1
    ttable.1.3 1
}