9

In conversations using Skype, I often want to share sound output (e.g. of a Youtube video) with other people I am talking with.

So I am looking for a way to route the output to the recording input (So that the other members hear the sound output), but I can still hear the output myself. Furthermore I want still be able to speak with them while sharing the sound output with them.

How would I do that? I would be very thankful!

Part of my question has been answered here: How to Pass/Record audio output as an input device? (but it only allows for setting the output stream as input, without overlapping the real microphone)

1 Answer 1

10
  1. Check id's

    $ pactl list short sources
    0   alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor    module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
    1   alsa_output.pci-0000_00_1b.0.analog-stereo.monitor  module-alsa-card.c  s16le 2ch 44100Hz   IDLE
    2   alsa_input.pci-0000_00_1b.0.analog-stereo   module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
    3   combined.monitor    module-combine-sink.c   s16le 2ch 44100Hz   SUSPENDED
    
    $ pactl list short sinks
    0   alsa_output.pci-0000_01_00.1.hdmi-stereo    module-alsa-card.c  s16le 2ch 44100Hz   RUNNING
    1   alsa_output.pci-0000_00_1b.0.analog-stereo  module-alsa-card.c  s16le 2ch 48000Hz   RUNNING
    2   combined    module-combine-sink.c   s16le 2ch 44100Hz   IDLE
    
  2. Make 2 virtual sinks, (Virtual1 mic+music, Virtual2 music)

    pactl load-module module-null-sink sink_name=Virtual1 sink_properties=device.description=Virtual1
    pactl load-module module-null-sink sink_name=Virtual2 sink_properties=device.description=Virtual2
    
  3. Loopback mic to Virtual1

    pactl load-module module-loopback latency_msec=1 sink=Virtual1
    
  4. Loopback Virtual2.monitor to Virtual1

    pactl load-module module-loopback latency_msec=1 sink=Virtual1 source=Virtual2.monitor
    
  5. Loopback Virtual2.monitor to Analog Stereo (In my case)

    pactl load-module module-loopback latency_msec=1 sink=1 source=Virtual2.monitor
    
  6. Then open pavucontrol:

    • Input Device: set fallback to Virtual1.monitor or using CLI:

      pactl set-default-source Virtual1.monitor
      
    • Output Devices: set default to Analog Stereo (In my case) or using CLI:

      pactl set-default-sink 1
      
    • Recording: confirm Skype from Virtual1.monitor or using CLI (I remove some lines from results, avconv as example):

      $ pactl list short clients
      23  protocol-native.c   chromium-browser
      24  protocol-native.c   chromium-browser
      45  protocol-native.c   pavucontrol
      237 protocol-native.c   avconv
      239 protocol-native.c   pactl
      
      $ pactl list short source-outputs
      35  0   45  protocol-native.c   float32le 1ch 25Hz
      36  1   45  protocol-native.c   float32le 1ch 25Hz
      37  2   45  protocol-native.c   float32le 1ch 25Hz
      38  3   45  protocol-native.c   float32le 1ch 25Hz
      39  4   45  protocol-native.c   float32le 1ch 25Hz
      41  0   45  protocol-native.c   float32le 1ch 25Hz
      42  1   45  protocol-native.c   float32le 1ch 25Hz
      52  1   45  protocol-native.c   float32le 1ch 25Hz
      54  1   237 protocol-native.c   s16le 2ch 48000Hz
      
      $ pactl move-source-output 54 Virtual1.monitor
      
    • Playback: set music player to Virtual2 (2nd null device), and confirm Skype in Analog Stereo. or through CLI (chromium as example, see previous pactl list short clients):

      $ pactl list short sink-inputs
      17  3   24  protocol-native.c   s16le 2ch 44100Hz
      58  0   -   module-combine-sink.c   s16le 2ch 44009Hz
      59  1   -   module-combine-sink.c   s16le 2ch 44100Hz
      
      $ pactl move-sink-input 17 Virtual2       
      

Simple Diagram (/,\ loopbacks from left to right):

            Microphone      ---
                               \                   
            Virtual1.mon    ------  Virtual1    >   Skype
                               /  
    VLC   > Virtual2.mon    ------  Virtual2
                               \
    Skype > AnalogSt.mon    ------  AnalogSt    >   Headset

To switch back (normal use), see Pulseaudio loopback unload audio output devices

  • Check module id:

    pactl list short modules
    
  • Unload single module (or one by one)

    pactl unload-module id
    
  • Or (reload with default modules):

    pulseaudio -k
    

Notes:

  • I have use sink id (Eg: 1) but if you want make a script it's better to use names. (I avoided that here because they are long).

  • How do I switch to another audio output sink in XFCE? contains nice script to get stream id from name to be used with move-sink-input and move-source-output.

  • I have used latency_msec=1 which may lead to high CPU usage. In audio conversation, you may not care about delay between music and microphone. You can remove it or increase it. But for recording mix, You may look for very small delay between music & microphone.

    As I have tested it, the delay is near half to one second.

  • I think some times its hard to figure out what going on like with Jack tools. It will be clear with graphic map:

enter image description here

11
  • Big thanks for the answer. But I am having issues: First of all in pavucontrol it only says "Monitor of Null Output". Secondly, people I am chatting with, complain about hearing their own echo. Could I blacklist the output of skype for the sound redirection?
    – Esokrates
    Feb 15, 2014 at 10:09
  • 1
    Ok, sorry I miss that, I have updated the answer, now it shows sink names as description in pavucontrol. pulseaudio -k to reset all change and start over. it should be easy now
    – user.dz
    Feb 15, 2014 at 10:26
  • 1
    By default it loopback the microhpone, but you can test it works.pactl load-module module-loopback source=2 latency_msec=1 sink=1 , you should hear mic in headset. then pactl unload-module 30 (30 is the id showed when you load-module.
    – user.dz
    Feb 15, 2014 at 10:47
  • 1
    Sneethser: Sorry to be unclear: Thank you everything works, as you instructed, but How could I replace the steps in pavucontrol with command line?
    – Esokrates
    Feb 15, 2014 at 11:16
  • 1
    Sneethsher: Nevermind, I added pactl unload-module module-loopback
    – Esokrates
    Mar 3, 2014 at 20:03

You must log in to answer this question.

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