My little son got a real profesional microphone on his birthday as he likes to sing but we realized that we have a big problem. There is no device to plug it into. The only thing capable to play some sound was a Panasonic soundbar but it does not have any ports available besides HDMI (ARC). It has a Bluetooth build in and from time to time I'm playing some music from my linux desktop using spotify. Wanted to make this little guy happy so decided to try to loop it via my desktop pc. Here is how to do it:

Install PulseAudio Volume Control (pavucontrol)

└─╼ sudo apt install pavucontrol

Loop back mic to speakers

Now you have to loop back your microphone to your speakers. Do this by running the following command:

└─╼ pactl load-module module-loopback latency_msec=1

Select right mic

On the Recording tab of pavucontrol, you can show all streams (combobox at the bottom) and then configure which microphone (if you have more than one) should loopback into the built-in analog stereo.

To stop it just run:

└─╼ pactl unload-module module-loopback

Some usefull pactl commands

List all modules

To list all loaded modules in pulseaudio just run pactl list short modules it will give you everything that is loaded.

└─╼ pactl list short modules 
0       module-device-restore 
1       module-stream-restore 
2       module-card-restore 
3       module-augment-properties 
4       module-switch-on-port-available 
5       module-switch-on-connect 
6       module-udev-detect 
7       module-alsa-card        device_id="1" name="pci-0000_01_00.1" card_name="alsa_card.pci-0000_01_00.1" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1" 
8       module-alsa-card        device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1" 
9       module-alsa-card        device_id="2" name="pci-0000_05_01.1" card_name="alsa_card.pci-0000_05_01.1" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1" 
10      module-bluetooth-policy 
11      module-bluetooth-discover 
12      module-bluez5-discover 
13      module-native-protocol-unix 
14      module-default-device-restore 
15      module-rescue-streams 
16      module-always-sink 
17      module-intended-roles 
18      module-suspend-on-idle 
19      module-console-kit 
20      module-systemd-login 
21      module-position-event-sounds 
22      module-role-cork 
23      module-filter-heuristics 
24      module-filter-apply 
25      module-x11-publish      display=:0 
26      module-x11-cork-request display=:0 
27      module-x11-xsmp display=:0 session_manager=local/desk:@/tmp/.ICE-unix/1301,unix/desk:/tmp/.ICE-unix/1301 
34      module-bluez5-device    path=/org/bluez/hci0/dev_6C_5A_B5_49_B6_DF autodetect_mtu=0 
36      module-loopback latency_msec=1

List all sinks

└─╼ pactl list sink-inputs
Sink Input #35
        Driver: protocol-native.c
        Owner Module: 13
        Client: 77
        Sink: 6
        Sample Specification: float32le 2ch 44100Hz
        Channel Map: front-left,front-right
        Format: pcm, format.sample_format = "\"float32le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
        Corked: no
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Buffer Latency: 48253 usec
        Sink Latency: 19097 usec
        Resample method: copy
        Properties:
                application.icon_name = "google-chrome"
                media.name = "Playback"
                application.name = "Chrome"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "11673"
                application.process.user = "bart"
                application.process.host = "desk"
                application.process.binary = "chrome"
                application.language = "pl_PL.UTF-8"
                window.x11.display = ":0"
                application.process.machine_id = "a2b294175f2c42048160e63ed8a1e0e5"
                application.process.session_id = "c2"
                module-stream-restore.id = "sink-input-by-application-name:Chrome"

Sink Input #37
        Driver: protocol-native.c
        Owner Module: 13
        Client: 81
        Sink: 6
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Format: pcm, format.sample_format = "\"s16le\""  format.rate = "44100"  format.channels = "2"  format.channel_map = "\"front-left,front-right\""
        Corked: no
        Mute: no
        Volume: front-left: 65535 / 100% / -0.00 dB,   front-right: 65535 / 100% / -0.00 dB
                balance 0.00
        Buffer Latency: 1563900 usec
        Sink Latency: 19054 usec
        Resample method: n/a
        Properties:
                media.role = "music"
                media.name = "Spotify"
                application.name = "Spotify"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "26680"
                application.process.user = "bart"
                application.process.host = "desk"
                application.process.binary = "spotify"
                window.x11.display = ":0"
                application.language = "pl_PL.UTF-8"
                application.process.machine_id = "a2b294175f2c42048160e63ed8a1e0e5"
                application.process.session_id = "c2"
                application.icon_name = "spotify-client"
                module-stream-restore.id = "sink-input-by-media-role:music"

You can see all the details and properties of all inputs. On the example above its youtube and Spotify running at the same time.

Set the volume for a specific device

  • this makes the volume 10% up
└─╼ pactl set-sink-volume 0 +10%
  • if you need the volume at 50%
└─╼ pactl set-sink-volume 0 50%
  • if you need to rock the entire place
└─╼ pactl set-sink-volume 0 150%
  • if you want to mute/unmute
└─╼ pactl set-sink-mute 0 toggle

Usefull links

  1. https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/
  2. https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/
  3. https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/CLI/
  4. https://linux.die.net/man/1/pactl