[SWLUG] asoundrc and recording what's playing

bascule asura at theexcession.co.uk
Wed Apr 17 03:08:23 UTC 2013


i've discovered that my soundcard doesn't have a stereo mix capture option to 
record what is playing, i've been reading around about using .asoundrc to 
create a virtual device along with using the snd_aloop module and i've managed 
to create a combined real and loopoback device that allows me to record what 
is played to the device and hear it at the same time, only there are a few 
issues:
in one version of my .asoundrc only one application can ply to the device at a 
time. which would be ok except other devices cannot play directly to the real 
hardware device when the virtual one is in use, even if two apps are both 
configured to play to the real device (which does do hardware mixing - it is a 
xonar ds) only one can play,
in another version of my .asoundrc i can play more than one stream at a time 
but recording from the loopback device introduces stutters, using audacity i 
can see the that the program is struggling to update as fast as it does with 
the first .asoundrc,

the first version of the .asoundrc is:
pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  capture.pm "hw:0,0"
}

pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}

pcm.mdev {
        type multi

        slaves.a.pcm "hw:Loopback,0,0"
        slaves.a.channels 2
        slaves.b.pcm "hw:0,0"
        slaves.b.channels 2

        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
-----------------------------------------------------------------------------------------------
the second version is:
            pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  capture.pcm "hw:0,0"
}

pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}


pcm.mdev {
  type multi
  slaves.a.pcm pcm.MixReal
  slaves.a.channels 2
  slaves.b.pcm pcm.MixLoopback
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}


pcm.MixReal {
  type dmix
  ipc_key 1024
  slave {
    pcm "hw:0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}

pcm.MixLoopback {
  type dmix
  ipc_key 1025
  slave {
    pcm "hw:Loopback,0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}
---------------------------------------------------------------------------

both these versions are based on what i found while googling and reading alsa 
documentation which  i found really confusing :)
what i don't understand is why if two apps are both using the alsa device 
hw:0,0 as their output and _not_ thte device defined in the asoundrc, and 
hw:0,0 is my xonar ds which has hardware mixing, the first .asoundrc gets in 
the way and stops both playing the the same time.

i would appreciate if anyone can help me, 
i was looking at alsaloop but i'm getting an error message about no 
libsamplerate upport which i'm still looking into

bascule
                                                   
-- 
"They said we should mount guards and they'd take steps."
"To the nearest place of safety, no doubt."
(Maskerade)




More information about the Swlug mailing list