Transferring sound from sink to virtual source

I wanna make a script that would create virtual source that would capture output of my sound from headphones and from my microphone so I can stream sound on Discord and other platforms.

I am still bit new to this stuff so I would appreciate a little explanation how to do it properly. :grinning:

pactl load-module module-null-sink sink_name="mic-and-desktop"
pactl load-module module-combine-sink sink_name="desktop-split" slaves="mic-and-desktop,$(pacmd dump | grep set-default-sink | cut -d ' ' -f2)"
pactl load-module module-loopback source="$(pacmd dump | grep set-default-source | cut -d ' ' -f2)" sink="mic-and-desktop"

and then you can open pavucontrol, and set the audio stream of Discord on the “Recording” tab to “Monitor of mic-and-desktop”. And then in the “Playback” tab you need to set the audio device of those applications that you want to “stream” on Discord to “desktop-split”.

If you want to “stream” all applications, then you can run pactl set-default-sink desktop-split. If you want every application to be able to record both your microphone and desktop audio, then run pactl set-default-source mic-and-desktop.monitor.

2 Likes

I did it and only I see Null output. There is no mic-and-desktop and desktop-split

Where?

In pavucontro and checked discord settings and there is also Null Output

Can you post the output of pactl list sources and pactl list sinks?

I have it in Polish language as it is my system language. The Null output I am talking about is called Puste wyjście in Polish. If needed I can translate stuff if necessary.

Here are Sources:

0. źródło
        Stan: SUSPENDED
        Nazwa: alsa_input.usb-Alpha_Imaging_Tech._Corp._Razer_Kiyo-02.analog-stereo
        Opis: Gaming Webcam [Kiyo] Analogowe stereo
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 2 k 16000 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 7
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 14119 /  22% / -40,00 dB
        Monitor odpływu: nie dotyczy
        Opóźnienie: 0 us, skonfigurowano 0 us
        Flagi: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Właściwości:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "Razer Kiyo"
                alsa.long_card_name = "Alpha Imaging Tech. Corp. Razer Kiyo at usb-0000:0a:00.3-1, high speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:1:1.2"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-1/3-1:1.2/sound/card2"
                udev.id = "usb-Alpha_Imaging_Tech._Corp._Razer_Kiyo-02"
                device.bus = "usb"
                device.vendor.id = "1532"
                device.vendor.name = "Razer USA, Ltd"
                device.product.id = "0e03"
                device.product.name = "Gaming Webcam [Kiyo]"
                device.serial = "Alpha_Imaging_Tech._Corp._Razer_Kiyo"
                device.form_factor = "webcam"
                device.string = "front:2"
                device.buffering.buffer_size = "128000"
                device.buffering.fragment_size = "64000"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analogowe stereo"
                device.description = "Gaming Webcam [Kiyo] Analogowe stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB1532:0e03"
                module-udev-detect.discovered = "1"
                device.icon_name = "camera-web-usb"
        Porty:
                analog-input-mic: Mikrofon (priority: 8700)
        Aktywny port: analog-input-mic
        Formaty:
                pcm

2. źródło
        Stan: RUNNING
        Nazwa: alsa_input.usb-BLUE_MICROPHONE_Blue_Snowball_201305-00.analog-stereo
        Opis: Blue Snowball Analogowe stereo
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 30
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 38295 /  58% / -14,00 dB
        Monitor odpływu: nie dotyczy
        Opóźnienie: 507 us, skonfigurowano 66666 us
        Flagi: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Właściwości:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "3"
                alsa.card_name = "Blue Snowball"
                alsa.long_card_name = "BLUE MICROPHONE Blue Snowball at usb-0000:01:00.0-5, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:01:00.0-usb-0:5:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-5/1-5:1.0/sound/card3"
                udev.id = "usb-BLUE_MICROPHONE_Blue_Snowball_201305-00"
                device.bus = "usb"
                device.vendor.id = "0d8c"
                device.vendor.name = "C-Media Electronics, Inc."
                device.product.id = "0005"
                device.product.name = "Blue Snowball"
                device.serial = "BLUE_MICROPHONE_Blue_Snowball_201305"
                device.string = "front:3"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analogowe stereo"
                device.description = "Blue Snowball Analogowe stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB0d8c:0005"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Porty:
                analog-input-mic: Mikrofon (priority: 8700)
        Aktywny port: analog-input-mic
        Formaty:
                pcm

3. źródło
        Stan: SUSPENDED
        Nazwa: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono.monitor
        Opis: Monitor of Arctis Pro Wireless Analogowe mono
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 1 k 44100 Hz
        Mapa kanałów: mono
        Właściciel modułu: 31
        Wyciszenie: nie
        Poziom głośności: mono: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Monitor odpływu: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono
        Opóźnienie: 0 us, skonfigurowano 0 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.description = "Monitor of Arctis Pro Wireless Analogowe mono"
                device.class = "monitor"
                alsa.card = "4"
                alsa.card_name = "Arctis Pro Wireless"
                alsa.long_card_name = "SteelSeries Arctis Pro Wireless at usb-0000:0a:00.3-3.3, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:3.3:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-3/3-3.3/3-3.3:1.0/sound/card4"
                udev.id = "usb-SteelSeries_Arctis_Pro_Wireless-00"
                device.bus = "usb"
                device.vendor.id = "1038"
                device.vendor.name = "SteelSeries ApS"
                device.product.id = "1294"
                device.product.name = "Arctis Pro Wireless"
                device.serial = "SteelSeries_Arctis_Pro_Wireless"
                device.string = "4"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Formaty:
                pcm

4. źródło
        Stan: SUSPENDED
        Nazwa: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-stereo.monitor
        Opis: Monitor of Arctis Pro Wireless Analogowe stereo
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 31
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Monitor odpływu: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-stereo
        Opóźnienie: 0 us, skonfigurowano 0 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.description = "Monitor of Arctis Pro Wireless Analogowe stereo"
                device.class = "monitor"
                alsa.card = "4"
                alsa.card_name = "Arctis Pro Wireless"
                alsa.long_card_name = "SteelSeries Arctis Pro Wireless at usb-0000:0a:00.3-3.3, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:3.3:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-3/3-3.3/3-3.3:1.0/sound/card4"
                udev.id = "usb-SteelSeries_Arctis_Pro_Wireless-00"
                device.bus = "usb"
                device.vendor.id = "1038"
                device.vendor.name = "SteelSeries ApS"
                device.product.id = "1294"
                device.product.name = "Arctis Pro Wireless"
                device.serial = "SteelSeries_Arctis_Pro_Wireless"
                device.string = "4"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Formaty:
                pcm

5. źródło
        Stan: SUSPENDED
        Nazwa: alsa_input.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono
        Opis: Arctis Pro Wireless Analogowe mono
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 1 k 44100 Hz
        Mapa kanałów: mono
        Właściciel modułu: 31
        Wyciszenie: nie
        Poziom głośności: mono: 65531 / 100% / -0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Monitor odpływu: nie dotyczy
        Opóźnienie: 0 us, skonfigurowano 0 us
        Flagi: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Właściwości:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "4"
                alsa.card_name = "Arctis Pro Wireless"
                alsa.long_card_name = "SteelSeries Arctis Pro Wireless at usb-0000:0a:00.3-3.3, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:3.3:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-3/3-3.3/3-3.3:1.0/sound/card4"
                udev.id = "usb-SteelSeries_Arctis_Pro_Wireless-00"
                device.bus = "usb"
                device.vendor.id = "1038"
                device.vendor.name = "SteelSeries ApS"
                device.product.id = "1294"
                device.product.name = "Arctis Pro Wireless"
                device.serial = "SteelSeries_Arctis_Pro_Wireless"
                device.string = "hw:4,0,0"
                device.buffering.buffer_size = "176400"
                device.buffering.fragment_size = "88200"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-mono"
                device.profile.description = "Analogowe mono"
                device.description = "Arctis Pro Wireless Analogowe mono"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB1038:1294"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Porty:
                steelseries-arctis-7-input: Mikrofon na słuchawkach (priority: 0)
        Aktywny port: steelseries-arctis-7-input
        Formaty:
                pcm

6. źródło
        Stan: IDLE
        Nazwa: mic-and-desktop.monitor
        Opis: Monitor of Puste wyjście
        Sterownik: module-null-sink.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 32
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Monitor odpływu: mic-and-desktop
        Opóźnienie: 0 us, skonfigurowano 2000000 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.description = "Monitor of Puste wyjście"
                device.class = "monitor"
                device.icon_name = "audio-input-microphone"
        Formaty:
                pcm

7. źródło
        Stan: SUSPENDED
        Nazwa: desktop-split.monitor
        Opis: Monitor Source of Simultaneous output to Puste wyjście, Arctis Pro Wireless Analogowe stereo
        Sterownik: module-combine-sink.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 34
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Monitor odpływu: desktop-split
        Opóźnienie: 0 us, skonfigurowano 0 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.description = "Monitor Source of Simultaneous output to Puste wyjście, Arctis Pro Wireless Analogowe stereo"
                device.class = "monitor"
                device.icon_name = "audio-input-microphone"
        Formaty:
                pcm

And here are sinks

1. odpływ
        Stan: IDLE
        Nazwa: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono
        Opis: Arctis Pro Wireless Analogowe mono
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 1 k 44100 Hz
        Mapa kanałów: mono
        Właściciel modułu: 31
        Wyciszenie: nie
        Poziom głośności: mono: 36045 /  55% / -15,58 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Źródło monitora: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-mono.monitor
        Opóźnienie: 42185 us, skonfigurowano 40000 us
        Flagi: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Właściwości:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "4"
                alsa.card_name = "Arctis Pro Wireless"
                alsa.long_card_name = "SteelSeries Arctis Pro Wireless at usb-0000:0a:00.3-3.3, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:3.3:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-3/3-3.3/3-3.3:1.0/sound/card4"
                udev.id = "usb-SteelSeries_Arctis_Pro_Wireless-00"
                device.bus = "usb"
                device.vendor.id = "1038"
                device.vendor.name = "SteelSeries ApS"
                device.product.id = "1294"
                device.product.name = "Arctis Pro Wireless"
                device.serial = "SteelSeries_Arctis_Pro_Wireless"
                device.string = "hw:4,0,0"
                device.buffering.buffer_size = "176400"
                device.buffering.fragment_size = "88200"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-mono"
                device.profile.description = "Analogowe mono"
                device.description = "Arctis Pro Wireless Analogowe mono"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB1038:1294"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Porty:
                steelseries-arctis-7-output-mono: Wyjście mono słuchawek (priority: 0)
        Aktywny port: steelseries-arctis-7-output-mono
        Formaty:
                pcm

2. odpływ
        Stan: RUNNING
        Nazwa: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-stereo
        Opis: Arctis Pro Wireless Analogowe stereo
        Sterownik: module-alsa-card.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 31
        Wyciszenie: nie
        Poziom głośności: front-left: 64881 /  99% / -0,26 dB,   front-right: 64881 /  99% / -0,26 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Źródło monitora: alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-stereo.monitor
        Opóźnienie: 40997 us, skonfigurowano 40000 us
        Flagi: HARDWARE DECIBEL_VOLUME LATENCY 
        Właściwości:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio #1"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "1"
                alsa.card = "4"
                alsa.card_name = "Arctis Pro Wireless"
                alsa.long_card_name = "SteelSeries Arctis Pro Wireless at usb-0000:0a:00.3-3.3, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:0a:00.3-usb-0:3.3:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-3/3-3.3/3-3.3:1.0/sound/card4"
                udev.id = "usb-SteelSeries_Arctis_Pro_Wireless-00"
                device.bus = "usb"
                device.vendor.id = "1038"
                device.vendor.name = "SteelSeries ApS"
                device.product.id = "1294"
                device.product.name = "Arctis Pro Wireless"
                device.serial = "SteelSeries_Arctis_Pro_Wireless"
                device.string = "hw:4,1,0"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analogowe stereo"
                device.description = "Arctis Pro Wireless Analogowe stereo"
                alsa.mixer_name = "USB Mixer"
                alsa.components = "USB1038:1294"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        Porty:
                steelseries-arctis-7-output-stereo: Słuchawki (priority: 0)
        Aktywny port: steelseries-arctis-7-output-stereo
        Formaty:
                pcm

3. odpływ
        Stan: RUNNING
        Nazwa: mic-and-desktop
        Opis: Puste wyjście
        Sterownik: module-null-sink.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 32
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Źródło monitora: mic-and-desktop.monitor
        Opóźnienie: 38337 us, skonfigurowano 40000 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.description = "Puste wyjście"
                device.class = "abstract"
                device.icon_name = "audio-card"
        Formaty:
                pcm

4. odpływ
        Stan: IDLE
        Nazwa: desktop-split
        Opis: Simultaneous output to Puste wyjście, Arctis Pro Wireless Analogowe stereo
        Sterownik: module-combine-sink.c
        Określenie próbki: s16le 2 k 44100 Hz
        Mapa kanałów: front-left,front-right
        Właściciel modułu: 34
        Wyciszenie: nie
        Poziom głośności: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                          balans 0,00
        Głośność podstawowa: 65536 / 100% / 0,00 dB
        Źródło monitora: desktop-split.monitor
        Opóźnienie: 0 us, skonfigurowano 40000 us
        Flagi: DECIBEL_VOLUME LATENCY 
        Właściwości:
                device.class = "filter"
                combine.slaves = "mic-and-desktop,alsa_output.usb-SteelSeries_Arctis_Pro_Wireless-00.analog-stereo"
                device.description = "Simultaneous output to Puste wyjście, Arctis Pro Wireless Analogowe stereo"
                device.icon_name = "audio-card"
        Formaty:
                pcm

I should add that my headphones appear as two output devices - one for games and the second for communication

Can you send a screenshot of what options are available in pavucontrol when you want to change the audio device of, let’s say, Discord?

Here is Recording tab:

And this is Playback tab:

Also these are output devices from Discord image

Is this the “Recording” tab?

I sent both tabs from pavucontrol, and the one from discord shows playback devices

Ohh, I missed them. You need to select “Monitor of Puste wyjscie” on the “Recording” tab. And then for the application you want to stream, you need to change to “Simulatenous output to Puste …” on the “Playback” tab.

Ok, so it works but friends say that the sound quality is terrible

Well, I’m not sure what may cause that. You could try lowering the volume and see if that changes anything. Or run parec -d mic-and-desktop.monitor | pacat to hear what others hear.