Configure Audio Input/Output by way of WirePlumber in Ubuntu 24.04

Configure Audio Input/Output by way of WirePlumber in Ubuntu 24.04

As , Ubuntu makes use of PipeWire as alternative of PulseAudio for its default sound server since Ubuntu 23.04. And, it now makes use of WirePlumber to handle pipewire session and coverage.

With WirePlumber, chances are you’ll configure extra about your sound output and enter. You can use Linux command to modify default audio enter/output machine, change quantity degree, and mute/un-mute sound and microphone.

As properly, chances are you’ll change the audio bit depth, pattern charge, resample high quality, and different properties for sure sound machine.

NOTE: This tutorial does NOT work for Ubuntu 22.04 and earlier, since they use PulseAudio as default. And, lua script does NOT work for twenty-four.10 & later as a result of coverage change!

Use wpctl Command

WirePlumber has a command line instrument known as wpctl. It’s helpful for getting your machine standing, properties, and alter some settings on the fly, similar to set default audio machine and alter quantity.

First, open up a terminal window (Ctrl+Alt+T) and run command:

wpctl standing

The command will output all of the audio units, audio sinks, and audio sources. The ones with * firstly are the defaults that in use. And, the numbers (e.g., 48, 49, 39 within the screenshot beneath) are the IDs.

To change default audio enter or output machine, when you have a number of units obtainable, then use command:

wpctl set-default ID

Here substitute the ID with the quantity you bought from the final wpctl standing command.

And, chances are you’ll use the instructions beneath to extend, lower, or set quantity. Which might be helpful for scripting objective or binding for keyboard shortcuts.

  • Increase quantity by 5% for default audio output, with a restrict of 150%:
    wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+
  • Decrease quantity by 5% for default audio output:
    wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
  • Set quantity of default output to 0.5:
    wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.5
  • Toggle mute/unmute for default audio output (or substitute toggle with 0 to unmute or 1 to mute):
    wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle

In the instructions above, chances are you’ll substitute @DEFAULT_AUDIO_SINK@ with @DEFAULT_AUDIO_SOURCE@ for the default audio enter (e.g., microphone). Or use ID quantity as an alternative for sure audio sink/supply.

Use lua script to configure Sound Properties

NOTE: This step solely works for WirePlumber 0.4.x (24.04 has 0.4.17). It has dropped lua script assist since model 0.5 (24.10 has v0.5.6).

Step 1: Get the Name of goal sound enter/ouput

Because the sound units’ ID numbers are dynamic and alter typically, it is advisable discover out the machine.identify or node.identify to let WireBlumder know which machine you need to configure.

First, run command beneath to search out out the ID of goal machine/sink you need to configure:

wpctl standing

Then, use the command beneath to show extra details about the goal object (substitute quantity 49 in response to final command).

wpctl examine 49

In the output, copy the worth of both “machine.identify” or “node.identify” to be used in subsequent step.

Step 2: Create & Edit lua script file

Ubuntu 24.04 to this point makes use of lua scripts for WirePlumber configuration. The default config information are positioned in /usr/share/wireplumber listing. While, person can create {custom} config information below /and many others/wireplumber or ~/.config/wireplumber directories.

1. For present person solely, press Ctrl+Alt+T on keyboard to open terminal and run instructions:

  • First, create the native wireplumber configuration folder:
    mkdir -p ~/.config/wireplumber/
  • Then, create the principal.lua.d sub-folder for storing lua scripts:
    mkdir -p ~/.config/wireplumber/principal.lua.d
  • Finally, create & open a {custom} script file with identify 51-alsa-custom.lua:
    gnome-text-editor ~/.config/wireplumber/principal.lua.d/51-alsa-custom.lua

    Here substitute gnome-text-editor depends upon your desktop atmosphere. Use musepad for XFCE, pluma for MATE, or nano command line textual content editor that works in most desktops.

    2. When file opens, paste the content material beneath and edit accordingly.

    rule = {
      matches = {
        {
          { "node.identify", "matches", "alsa_output.pci-0000_00_1f.3.analog-stereo" },
        },
      },
      apply_properties = {
          ["node.description"]       = "Laptop Built-in Speaker",
          ["audio.format"]           = "S32LE",
          ["audio.rate"]             = 48000
      },
    }
    desk.insert(alsa_monitor.guidelines,rule)

    IMPARTANT: Mis-configuration and typo errors on this file MAY break the sound output or enter! Do it fastidiously!

    Here it is advisable:

    • Replace alsa_output.pci-0000_00_1f.3.analog-stereo with yours audio machine/sink node identify (See Step 1).
    • Add extra (or delete if want) and alter audio settings below “apply_properties” part accordingly. Other properties embrace:
      • [“node.disabled”] = false,
      • [“priority.driver”] = 100,
      • [“priority.session”] = 100,
      • [“node.pause-on-idle”] = false,
      • [“dither.noise”] = 0,
      • [“dither.method”] = “none”, — “rectangular”, “triangular” or “shaped5”
      • [“audio.channels”] = 2,
      • [“session.suspend-timeout-seconds”] = 5, — 0 disables droop

      For extra choices, both learn the /usr/share/wireplumber/principal.lua.d/50-alsa-config.lua file, or see the official documentation for machine/node properties (some could also be not obtainable since WireBlumder is previous in Ubuntu).

      For nano command line textual content editor, press Ctrl+S to save lots of file and Ctrl+X to exit.

      Step 3: Apply Changes

      To apply the brand new configuration file, merely run the command beneath to restart the wireblumder service:

      systemctl --user restart wireplumber.service

      Undo:

      Any incorrect settings or typo errors you made in final step might break the sound output/enter. In the case, simply delete that file by way of the command beneath:

      rm ~/.config/wireplumber/principal.lua.d/51-alsa-custom.lua

      Then restart the service (see Step 3) ought to restore all the things to default.

HI-FI News

by way of UbuntuHandbook https://ift.tt/2hoz3QN

October 1, 2024 at 05:00PM