Is PipeWire ready for using?

I updated my home-manager and it told me to pick either PulseAudio or PipeWire for PulseEffects.

I hadn’t heard of PipeWire before, it wants to support both Jack and PA usecases, which sounds good to me.

Is it ready enough for using on my laptop? What should I configure on the NixOS side?

5 Likes

I’m using it without problems. I just added something like this in my configurations.nix:

  services.pipewire = {
    enable = true;
    alsa = {
      enable = true;
      support32Bit = true;
    };
    pulse.enable = true;
  };
8 Likes

I tried version 0.3.18 and while it mostly works I did have some glitches (mainly when switching outputs in pavucontrol-qt, but sometimes sound would stop working in firefox). so for now I reverted back to pulseaudio.

1 Like

I would say the development of pipewire is at a point where the base cases for endusers should mostly be satisfied. In particular the pulseaudio plugin has a lot to do with that. If you pick through Home · Wiki · PipeWire / pipewire · GitLab and the issue tracker you will see issues with things on the pulseaudio implementation side not working as well or the same (IIRC).
My personal evaluation is its in a phase of broader testing, so IMHO experimental but I have used it for certain purposes and those purposes did work (but not perfectly). I really wouldn’t expect it to just yet.

5 Likes

Great responses, thanks! I’ll give it a shot, but I’m worried that Teams and friends will misbehave during customer meetings.

Update:
I am using PipeWire now and everything seems to be working fine, including high quality bluetooth calls, with this configuration (I import it as sound.nix):

{ config, pkgs, options, ... }:

{
  # Not sure if needed actually
  boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest;

  # High quality BT calls
  hardware.bluetooth.enable = true;
  hardware.bluetooth.hsphfpd.enable = true;

  # Pipewire config
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    # No idea if I need this
    alsa.support32Bit = true;
    pulse.enable = true;

    # High quality BT calls
    media-session.config.bluez-monitor.rules = [
      {
        # Matches all cards
        matches = [{ "device.name" = "~bluez_card.*"; }];
        actions = {
          "update-props" = {
            "bluez5.auto-connect" = [ "hfp_hf" "hsp_hs" "a2dp_sink" ];
          };
        };
      }
      {
        matches = [
          # Matches all sources
          { "node.name" = "~bluez_input.*"; }
          # Matches all outputs
          { "node.name" = "~bluez_output.*"; }
        ];
        actions = {
          "node.pause-on-idle" = false;
        };
      }
    ];
  };
}

6 Likes

Hi,

Is the same setup still working for you? Whenever I enable hsphfpd, my bluetooth headset mic input is not being detected anymore. Without I am able to achieve various degrees of success, but it’s never quite right (either quality seems off, or something is not working, or I get AAC output turned off when I enable BT input).

I an quite surprised by the posts saying that pipewire is less stable than pulseaudio: in my case pulseaudio was less stable than pipewire and was getting kind of crazy (especially with bluetooth). Someone in a computer music irc channel told me to try pipewire as pulseaudio was not heavily developed anymore and would be eventually replaced by pipewire and that it handles bluetooth much better… And in my experience it is true, to the point that Ubuntu announced that Ubuntu 22.10 will run pipewire instead of pulseaudio!

Pipewire was so much of a breeze for me, not only with bluetooth but also to run music applications that need jack. Now I can super easily use both jack and pulseaudio applications at the same time!

Here is my file for reference:

{ config, pkgs, lib, ... }:
{
  # pulseaudio is buggy, let's use pipewire instead!
  # Remove sound.enable or turn it off if you had it set previously, it seems to cause conflicts with pipewire
  sound.enable = false;
  
  # Not sure if required...
  hardware.bluetooth.enable = true;

  # Apparently is useful sometimes, not sure when, I did not saw
  # any improvement with it.
  users.extraGroups.audio.members = [ "leo" ];

  # rtkit is optional but recommended
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    jack.enable = true;

    # # use the example session manager (no others are packaged yet so this is enabled by default,
    # # no need to redefine it in your config for now)
    # media-session.enable = true;
    # # If you want to enable the mSBC codec for slightly better sound quality in calls via bluetooth headsets
    # # you can add this. Note again that arrays are replaced, not merged, so you need to list the default items
    # # (the "don't pause nodes on idle" rule) here if you want to keep them.
    # media-session.config.bluez-monitor.rules = [
    #   {
    #     # Matches all cards
    #     matches = [ { "device.name" = "~bluez_card.*"; } ];
    #     actions = {
    #       "update-props" = {
    #         "bluez5.reconnect-profiles" = [ "hfp_hf" "hsp_hs" "a2dp_sink" ];
    #         # mSBC is not expected to work on all headset + adapter combinations.
    #         "bluez5.msbc-support" = true;
    #       };
    #     };
    #   }
    #   {
    #     matches = [
    #       # Matches all sources
    #       { "node.name" = "~bluez_input.*"; }
    #       # Matches all outputs
    #       { "node.name" = "~bluez_output.*"; }
    #     ];
    #     actions = {
    #       "node.pause-on-idle" = false;
    #     };
    #   }
    # ];
  };

  # To display icon in systray KDE... and seems to solve the volume key issues!
  environment.systemPackages = with pkgs; [
    # kmix # I prefer plasma-pa applet: when scrolling on kmix the sound is played on internal card instead of default sink...
    plasma-pa
    pulseaudioFull # needed to provide additional tools (pipewire can be configured via pulseaudio commands) and needed by zoom to provide advanced share screen options (optimized for video…)
  ];

}

@dpc Have you tried to change the bluetooth codec in pavucontrol’s tab? You have various tradeoffs between sound quality and microphone enabled, maybe it tried to maximize sound quality here and therefore disabled the mic.

Edit: these were also a related discution il n matrix, K900 sayed

You might want to try unstable, it has a newer Pipewire version that has some fixes around Bluetooth handling

1 Like

Yes, pipewire is already better than pulsaudio was. I just have this one specific issue.

With hsphfpd disabled I am able to switch between codecs just fine, but I either get high quality (AAC) output without BT headset output, or both input and output, but in a crappy quality with mSBC codec.

I’ll try unstable, I can always revert back. :smiley:

Same behavior though what shows up in Gnome’s control center’s “Sound” is a bit different. With hsphfpd enabled I only get “Headphone” in the outputs and no input. When I disable it, I get two outputs: “Headset” and “Headphone”, but only one input: “Headset”. I can’t use Heaphone output (high quality) with Headset input. So basically hsphfpd doesn’t work and makes things worse, it seems. Previously it worked the same, but was showing up multiple codecs instead of just a “bluetooth profile(?)”.

AFAIK bluetooth can’t do high quality duplex audio (and LE audio is not there yet).

1 Like

I did notice that I have to disconnect the headset manually and connect again, and then it will have a bunch of profiles including headset.

It’s not great but better than it used to be. Ideally, it should automatically use the headset mode only when the mic is actually in use.

I find it crazy that a Linux OS, Android, has a bluetooth stack that works just fine and we can’t use it on the desktop :frowning:

3 Likes

Yes, crappy audio with mic or quality audio without mic. Those are the two options. It’s the same case in Android, it just switches between them automatically when you enter/leave a call.

It does, and you can configure pipewire/pulse to do the same. However, IME, regardless of what headset is used, android’s audio-with-mic is markedly less crappy than that of a desktop Linux distro.

Android’s is “I can tell the difference if I listen closely, but without a trained ear probably couldn’t tell you which is the better one in a blind test”. Desktop Linux’s is “holy crap I can hardly understand the person I’m speaking to, and they complain about me being underwater”.

I’ve been observing this with various headsets, phones and distros for a decade now, and I still don’t know why. Is android simply configured to use a higher bitrate for mSBC? Do they use a totally different implementation (don’t think so since I think I used codecs ported from android on gentoo for a while)? Do they emulate stereo sound from mono output? One day I’ll find out.

3 Likes

So it seems that with this configuration on 23.05, the headset switching happens automatically when the microphone is requested and it seems to be good quality. I used to have a bunch of bluetooth voodoo in there, but that’s no longer needed:

  # disable pulseaudio
  hardware.pulseaudio.enable = false;
  # enable realtime processing
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    wireplumber.enable = true;

    # support alsa and pulseaudio
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };
7 Likes

Since you mention recent improvements, at some points it was needed to manually change the sound input to/from hdmi when (un)plugging a screen like a TV (which was sometimes a bit disturbing, for instance if you forgot to switch back after disconnecting the sound, you might be confused why you have no sound). Now, it is automatically done! (at least working on KDE plasma)

1 Like

Pipewire just works for me, and it automatically chooses the best settings for bit depth and sample rate (I believe I am at 32bit 48KHz currently)

It has better latency, less CPU usage and less likely to have distortion issues than Pulseaudio (at least in my case), I highly recommend

3 Likes

Whoa, it does indeed sound better than it used to. The microphone quality still seems poor (I sound very muffled when testing with gUM Test Page), but at least what I hear is quite ok.

Either is miles ahead of what it used to be though, wonder when and what changed.

1 Like

anything special needed to get it to behave with my Bluetooth headset? I feel like I had to plug in some stuff from here Bluetooth - NixOS Wiki back in the day for pulseaudio and things “just work” as is. Nevertheless, I would like to try pipewire so was curious if you’ve had any issues with bt headsets or whatnot - thanks in advance

edit: just read wmertens comment so I’ll see if it just works for me