Listen in real-time to microphone to verify it #30

Open
opened 2024-06-25 13:40:36 +02:00 by Benjamin_Loison · 17 comments
Owner

I have in mind Linux Mint 21.3 Cinnamon and Debian 12 GNOME.

Related to Improve_websites_thanks_to_open_source/issues/704 and Benjamin-Loison/cinnamon/issues/106.

+3

I have in mind Linux Mint 21.3 Cinnamon and Debian 12 GNOME. Related to [Improve_websites_thanks_to_open_source/issues/704](https://codeberg.org/Benjamin_Loison/Improve_websites_thanks_to_open_source/issues/704) and [Benjamin-Loison/cinnamon/issues/106](https://github.com/Benjamin-Loison/cinnamon/issues/106). +3
Author
Owner

Currently I use Audacity to record for a few seconds, then listen these few seconds.

Currently I use Audacity to record for a few seconds, then listen these few seconds.
Author
Owner

Also to check if physically toggling mute on my microphone makes a loud sound.

Also to check if physically toggling mute on my microphone makes a loud sound.
Author
Owner

Benjamin-Loison/obs-studio/issues/39 meets my needs.

GNOME control center on Debian 13 GNOME and Ubuntu 26.04 does not help.

[Benjamin-Loison/obs-studio/issues/39](https://github.com/Benjamin-Loison/obs-studio/issues/39) meets my needs. GNOME control center on Debian 13 GNOME and Ubuntu 26.04 does not help.
Author
Owner

DuckDuckGo and Google search Ubuntu listen to microphone and Ubuntu listen to given microphone.

https://chat.mistral.ai/work/5a0336c6-beb9-44c4-9cb2-50ddf675a4cf

Mistral: conv_01a17e0166017329aa0ae0ff48d7d5f0

On Debian 13 GNOME how to map a given microphone to audio output?

GLM 5.3:

On Debian 13 ("Trixie"), GNOME uses PipeWire (with WirePlumber as the session manager) as the sound server, so the way to route a microphone into your output device is to create a loopback between the source and the sink. Here are the main ways to do it:

Option 1: Quick one-liner with pw-loopback

pw-loopback -m '[FL FR]' --capture-props='media.class=Audio/Source node.name=mic_to_out'

But to target a specific microphone and a specific output, first list your devices:

pactl list sources short    # find your mic, e.g. alsa_input.usb-...
pactl list sinks short      # find your output, e.g. alsa_output.pci-...

Then run:

pw-loopback \
  --capture-props='target.object=<MIC_NAME> media.class=Audio/Source' \
  --playback-props='target.object=<SINK_NAME>'

This runs in the foreground; stop it with Ctrl+C. Use nohup pw-loopback ... & to keep it running in the background.

Option 2: Graphical patchbay (easiest to visualize)

Install qpwgraph (Qt) or Helvum (GTK):

sudo apt install qpwgraph

Launch it, and you'll see your microphone node on the left (outputs) and your output device node on the right (inputs). Drag a connection line from the mic's output ports to the sink's input playback_FL/FR ports. You'll immediately hear the mic through the speakers.

Option 3: PulseAudio-compatible module via pactl

PipeWire's PulseAudio compatibility layer still supports the classic loopback module:

pactl load-module module-loopback source=<MIC_NAME> sink=<SINK_NAME>

To remove it later:

pactl unload-module module-loopback

Making it persistent

Loopback connections created this way disappear on reboot. To make it permanent:

  • qpwgraph has a "save/restore graph" feature (save the .qpwgraph file and enable auto-restore), or
  • Create a small systemd user service that runs the pw-loopback command from Option 1, or
  • Add a WirePlumber config snippet in ~asound/~/.config/wireplumber/ — e.g. a loopback table in ~/.config/wireplumber/bluetooth.lua.d/-style config files isn't needed for this; the systemd user service is the simplest robust approach.

⚠️ A word of caution

If you map a mic directly to speakers, use headphones. Feeding a live microphone back into desktop speakers in the same room will cause a loud feedback loop (squeal) very quickly. Also note there may be a small latency (a fraction of a second), which is normal for loopback monitoring.

Recommendation: For a one-time or occasional need, use qpwgraph (visual, instant, easy to disconnect). For a scripted/persistent setup, use the pw-loopback command in a systemd user service.

Quick one-liner with pw-loopback

was not helping on Ubuntu 26.04 laptop:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAv+IZweaQ78xNYSMGqQYzuYKlHtM3f3I+BoxeCx7FaAIw
o/l2fUCE3YKkjhOiG4xn25P0QDlF+WbEcHzySMzV1Ryj+Z8DLYDOBG9UgwoAmKuw
0kIBEXtoZPWvRLVG7z0Q5Pm3y9lYJ2OOFnvxy96lPzqyca2wn7+LmeqioL2FQKzw
agF3jhU82x0XTCyx1D85jTi2Txc=
=KYc4
-----END PGP MESSAGE-----

Similarly to

PulseAudio-compatible module via pactl

was tested on the same setup without luck:

pw-loopback --capture-props='target.object=<MIC_NAME> media.class=Audio/Source' --playback-props='target.object=<SINK_NAME>'

if I remember correctly.

DuckDuckGo and Google search *Ubuntu listen to microphone* and *Ubuntu listen to given microphone*. https://chat.mistral.ai/work/5a0336c6-beb9-44c4-9cb2-50ddf675a4cf Mistral: `conv_01a17e0166017329aa0ae0ff48d7d5f0` > On Debian 13 GNOME how to map a given microphone to audio output? <details> <summary>GLM 5.3:</summary> On Debian 13 ("Trixie"), GNOME uses **PipeWire** (with WirePlumber as the session manager) as the sound server, so the way to route a microphone into your output device is to create a loopback between the source and the sink. Here are the main ways to do it: ## Option 1: Quick one-liner with `pw-loopback` ```bash pw-loopback -m '[FL FR]' --capture-props='media.class=Audio/Source node.name=mic_to_out' ``` But to target a *specific* microphone and a *specific* output, first list your devices: ```bash pactl list sources short # find your mic, e.g. alsa_input.usb-... pactl list sinks short # find your output, e.g. alsa_output.pci-... ``` Then run: ```bash pw-loopback \ --capture-props='target.object=<MIC_NAME> media.class=Audio/Source' \ --playback-props='target.object=<SINK_NAME>' ``` This runs in the foreground; stop it with Ctrl+C. Use `nohup pw-loopback ... &` to keep it running in the background. ## Option 2: Graphical patchbay (easiest to visualize) Install **qpwgraph** (Qt) or **Helvum** (GTK): ```bash sudo apt install qpwgraph ``` Launch it, and you'll see your microphone node on the left (outputs) and your output device node on the right (inputs). Drag a connection line from the mic's `output` ports to the sink's `input` `playback_FL/FR` ports. You'll immediately hear the mic through the speakers. ## Option 3: PulseAudio-compatible module via pactl PipeWire's PulseAudio compatibility layer still supports the classic loopback module: ```bash pactl load-module module-loopback source=<MIC_NAME> sink=<SINK_NAME> ``` To remove it later: ```bash pactl unload-module module-loopback ``` ## Making it persistent Loopback connections created this way disappear on reboot. To make it permanent: - **qpwgraph** has a "save/restore graph" feature (save the `.qpwgraph` file and enable auto-restore), or - Create a small systemd **user service** that runs the `pw-loopback` command from Option 1, or - Add a WirePlumber config snippet in `~asound`/`~/.config/wireplumber/` — e.g. a `loopback` table in `~/.config/wireplumber/bluetooth.lua.d/`-style config files isn't needed for this; the systemd user service is the simplest robust approach. ## ⚠️ A word of caution If you map a mic directly to speakers, **use headphones**. Feeding a live microphone back into desktop speakers in the same room will cause a loud feedback loop (squeal) very quickly. Also note there may be a small latency (a fraction of a second), which is normal for loopback monitoring. **Recommendation:** For a one-time or occasional need, use **qpwgraph** (visual, instant, easy to disconnect). For a scripted/persistent setup, use the `pw-loopback` command in a systemd user service. </details> > Quick one-liner with `pw-loopback` <details> <summary>was not helping on Ubuntu 26.04 laptop:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdAv+IZweaQ78xNYSMGqQYzuYKlHtM3f3I+BoxeCx7FaAIw o/l2fUCE3YKkjhOiG4xn25P0QDlF+WbEcHzySMzV1Ryj+Z8DLYDOBG9UgwoAmKuw 0kIBEXtoZPWvRLVG7z0Q5Pm3y9lYJ2OOFnvxy96lPzqyca2wn7+LmeqioL2FQKzw agF3jhU82x0XTCyx1D85jTi2Txc= =KYc4 -----END PGP MESSAGE----- ``` </details> Similarly to > PulseAudio-compatible module via pactl was tested on the same setup without luck: ```bash pw-loopback --capture-props='target.object=<MIC_NAME> media.class=Audio/Source' --playback-props='target.object=<SINK_NAME>' ``` if I remember correctly.
Author
Owner
Based on the remembrance of PipeWire by the person:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdA9ABx36jp5bNYknUEs3d2hjW/r7HOGVmZwqjStO3xyhkw
g2uCWQY9WVWLqy5roTbz32MWtvnQq1vwg4eMKaMpw6ZjmG5EYhZFRHzbkILdvDtY
0kIBKtabEUCYeZuVdlhI4g9G6cX9oyE9HDCRVfe4Ok8MnsfCi1cosZgHpJMFzmL5
F2hACcsa7spvKueqPSkCT+OjmZM=
=0xw6
-----END PGP MESSAGE-----
pipewire
Output:
[E][18:37:35.615085] mod.protocol-native | [module-protocol-:  803 lock_socket()] server 0x565109e57200: unable to lock lockfile '/run/user/1000/pipewire-0.lock': Resource temporarily unavailable (maybe another daemon is running)
[E][18:37:35.615183] pw.conf      | [          conf.c:  602 load_module()] 0x565109e35610: could not load mandatory module "libpipewire-module-protocol-native": Resource temporarily unavailable
[E][18:37:35.616447] default      | [      pipewire.c:  124 main()] failed to create context: Resource temporarily unavailable

The same person remembered on Zoom being able to share audio output on a web-browser, but I agrees that on Debian other desktop environment than GNOME he is unable to do so on Firefox or Chromium (I don't remember which one or if both).

I confirm that both Firefox and Chromium have the issue (not considering a Chromium tab to be shared).

Related to Benjamin_Loison/firefox/issues/344 and Benjamin_Loison/chromium/issues/46.

The Unix Stack Exchange question 229140 may help.

<details> <summary>Based on the remembrance of PipeWire by the person:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdA9ABx36jp5bNYknUEs3d2hjW/r7HOGVmZwqjStO3xyhkw g2uCWQY9WVWLqy5roTbz32MWtvnQq1vwg4eMKaMpw6ZjmG5EYhZFRHzbkILdvDtY 0kIBKtabEUCYeZuVdlhI4g9G6cX9oyE9HDCRVfe4Ok8MnsfCi1cosZgHpJMFzmL5 F2hACcsa7spvKueqPSkCT+OjmZM= =0xw6 -----END PGP MESSAGE----- ``` </details> ```bash pipewire ``` <details> <summary>Output:</summary> ``` [E][18:37:35.615085] mod.protocol-native | [module-protocol-: 803 lock_socket()] server 0x565109e57200: unable to lock lockfile '/run/user/1000/pipewire-0.lock': Resource temporarily unavailable (maybe another daemon is running) [E][18:37:35.615183] pw.conf | [ conf.c: 602 load_module()] 0x565109e35610: could not load mandatory module "libpipewire-module-protocol-native": Resource temporarily unavailable [E][18:37:35.616447] default | [ pipewire.c: 124 main()] failed to create context: Resource temporarily unavailable ``` </details> The same person remembered on Zoom being able to share audio output on a web-browser, but I agrees that on Debian other desktop environment than GNOME he is unable to do so on Firefox or Chromium (I don't remember which one or if both). I confirm that both Firefox and Chromium have the issue (not considering a Chromium tab to be shared). Related to [Benjamin_Loison/firefox/issues/344](https://codeberg.org/Benjamin_Loison/firefox/issues/344) and [Benjamin_Loison/chromium/issues/46](https://codeberg.org/Benjamin_Loison/chromium/issues/46). [The Unix Stack Exchange question 229140](https://unix.stackexchange.com/q/229140) may help.
Author
Owner

DuckDuckGo and Google search Linux merge 2 microphones.

The Ask Ubuntu question 868817 may help.

Related to #31.

DuckDuckGo and Google search *Linux merge 2 microphones*. [The Ask Ubuntu question 868817](https://askubuntu.com/q/868817) may help. Related to #31.
Author
Owner

https://www.reddit.com/r/linux4noobs/comments/1lblerw/comment/mxy4wx5/

pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description=Combined_mics

Don't use spaces, use underscores. There's probably a way to use spaces but I gave up on it.

pactl load-module module-loopback latency_msec=60 adjust_time=6 source=name_of_mic_source sink=sink_combined_mics

once for each microphone works as wanted.

pactl list short sources helps figuring out name_of_mic_source values.

Are other arguments necessary?

Does it hold a reboot?

All sinks have an associated source, created automatically, which is named "Monitor of ". So to record from your new sink you would record from the source called "Monitor of ".

https://www.reddit.com/r/linux4noobs/comments/1lblerw/comment/mxy4wx5/ ```bash pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description=Combined_mics ``` > Don't use spaces, use underscores. There's probably a way to use spaces but I gave up on it. ```bash pactl load-module module-loopback latency_msec=60 adjust_time=6 source=name_of_mic_source sink=sink_combined_mics ``` once for each microphone works as wanted. `pactl list short sources` helps figuring out `name_of_mic_source` values. Are other arguments necessary? Does it hold a reboot? > All sinks have an associated source, created automatically, which is named "Monitor of <name of sink>". So to record from your new sink you would record from the source called "Monitor of <whatever you called your sink>".
Author
Owner
Related to [Benjamin_Loison/gnome-control-center/-/work_items/73](https://gitlab.gnome.org/Benjamin_Loison/gnome-control-center/-/work_items/73).
Author
Owner

You create a new audio sink using the null module.

You connect one mic source to the new sink using the loopback module.

See the links above for extra parameters but these should be enough.

Please note that whenever you do a pactl load-module you get a number. That's the ID of the newly created module. If you want to undo the setup cleanly you should remember the IDs of the 3 modules (the null module for the sink and the 2 loopback modules) and use pactl unload-module . Alternatively if you don't wanna remember the IDs you can unload all modules of a certain type using pactl unload-module module-null-sink and pactl unload-module module-loopback – which is fine, assuming you don't also have other setups that depend on null or loopback modules.

> You create a new audio sink using [the null module](https://docs.pipewire.org/page_pulse_module_null_sink.html). > > You connect one mic source to the new sink using [the loopback module](https://docs.pipewire.org/page_pulse_module_loopback.html). > See the links above for extra parameters but these should be enough. > Please note that whenever you do a pactl load-module you get a number. That's the ID of the newly created module. If you want to undo the setup cleanly you should remember the IDs of the 3 modules (the null module for the sink and the 2 loopback modules) and use pactl unload-module <id>. Alternatively if you don't wanna remember the IDs you can unload all modules of a certain type using pactl unload-module module-null-sink and pactl unload-module module-loopback – which is fine, assuming you don't also have other setups that depend on null or loopback modules.
Author
Owner

On Debian 13 GNOME HP laptop:

pactl list sources short
Output:
56	alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink.monitor	PipeWire	s24-32le 2ch 48000Hz	SUSPENDED
57	alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink.monitor	PipeWire	s24-32le 2ch 48000Hz	SUSPENDED
58	alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink.monitor	PipeWire	s24-32le 2ch 48000Hz	SUSPENDED
59	alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink.monitor	PipeWire	s32le 2ch 48000Hz	RUNNING
60	alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic2__source	PipeWire	s24-32le 2ch 48000Hz	SUSPENDED
61	alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic1__source	PipeWire	s32le 4ch 48000Hz	SUSPENDED
On Debian 13 GNOME HP laptop: ```bash pactl list sources short ``` <details> <summary>Output:</summary> ``` 56 alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI3__sink.monitor PipeWire s24-32le 2ch 48000Hz SUSPENDED 57 alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI2__sink.monitor PipeWire s24-32le 2ch 48000Hz SUSPENDED 58 alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__HDMI1__sink.monitor PipeWire s24-32le 2ch 48000Hz SUSPENDED 59 alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink.monitor PipeWire s32le 2ch 48000Hz RUNNING 60 alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic2__source PipeWire s24-32le 2ch 48000Hz SUSPENDED 61 alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Mic1__source PipeWire s32le 4ch 48000Hz SUSPENDED ``` </details>
Author
Owner
pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description=Combined_mics
536870916
```bash pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description=Combined_mics ``` ``` 536870916 ```
Author
Owner

image.png

![image.png](attachments/281feabd-c5b2-4c63-9cd7-6259e1ba2e13)
103 KiB
Author
Owner

After reboot I do not have anymore Combined_mics.

Could wonder how to keep it across reboots, but I fear temporary mics being plugged to Combined_mics having their identifiers changing along time as their randomness may suggest.

After reboot I do not have anymore `Combined_mics`. Could wonder how to keep it across reboots, but I fear temporary mics being plugged to `Combined_mics` having their identifiers changing along time as their randomness may suggest.
Author
Owner
pactl load-module module-loopback latency_msec=60 adjust_time=6 source=name_of_mic_source sink=sink_combined_mics
536870917

so a not existing source may not be an issue.

```bash pactl load-module module-loopback latency_msec=60 adjust_time=6 source=name_of_mic_source sink=sink_combined_mics ``` ``` 536870917 ``` so a not existing source may not be an issue.
Author
Owner

I have verified that Extron random part and NearStream identifier do not change even if unplugged and replugged, computer reboot and Extron system powered off.

pactl load-module
You have to specify a module name and arguments.
pactl load-module module-null-sink
536870918

creates in Debian 13 GNOME HP laptop GNOME control center null-sink Audio/Sink sink.

pactl load-module module-null-sink sink_name=sink_combined_mics
536870919

creates in GNOME control center sink_combined_mics Audio/Sink sink.

pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description='Combined mics'
pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties='device.description=Combined mics'
pactl load-module module-null-sink sink_name=sink_combined_mics 'sink_properties=device.description=Combined mics'

create in GNOME control center Combined. Same with " for all 3 possibilities.

All returned integers.

Tracked at Benjamin_Loison/pulseaudio/-/work_items/1.

I have verified that Extron random part and NearStream identifier do not change even if unplugged and replugged, computer reboot and Extron system powered off. ```bash pactl load-module ``` ``` You have to specify a module name and arguments. ``` ```bash pactl load-module module-null-sink ``` ``` 536870918 ``` creates in Debian 13 GNOME HP laptop GNOME control center *null-sink Audio/Sink sink*. ```bash pactl load-module module-null-sink sink_name=sink_combined_mics ``` ``` 536870919 ``` creates in GNOME control center *sink_combined_mics Audio/Sink sink*. ```bash pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties=device.description='Combined mics' pactl load-module module-null-sink sink_name=sink_combined_mics sink_properties='device.description=Combined mics' pactl load-module module-null-sink sink_name=sink_combined_mics 'sink_properties=device.description=Combined mics' ``` create in GNOME control center *Combined*. Same with `"` for all 3 possibilities. All returned integers. Tracked at [Benjamin_Loison/pulseaudio/-/work_items/1](https://gitlab.freedesktop.org/Benjamin_Loison/pulseaudio/-/work_items/1).
Author
Owner
[Benjamin_Loison/pulseaudio/-/work_items/2](https://gitlab.freedesktop.org/Benjamin_Loison/pulseaudio/-/work_items/2) would help.
Author
Owner

I suspect that have to temporarily toggle room dashboard to Micros plafond to avoid echo.

I suspect that have to temporarily toggle room dashboard to *Micros plafond* to avoid echo.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#30