* Background

About a year ago I switched from using raw ALSA to pulseaudio.
Linux on my laptop just cut over to using pipewire with pipewire-pulse
providing a compatibility drop-in.
However that drop-in does not automatically provide all my pulse
customizations --- see [[../pulse/readme.org][pulse readme]] for details.
These notes document what broke and how I fix them.

* Out-Of-The-Box Breakages

  - No left or right TTS devices.
  - Auditory Icons go back to using aplay rather than paplay with samples loaded
  - X-Windows bell went away ---
  - Volume in emacspeak minor mode line went away
  - ToDo: Implement all customizations from default.pa in native pipewire.

* Cautionary Notes

  - Make sure you install pipewire-alsa and pipewire-pulse --
        these enable compatibility.
  - Do not install any pipewire conf files  unless tested (how?); a
   broken conf file  can lose *all* audio.
   

* What I have Learn

  - CLI tool pactl, pamixer work in pipewire, even when there is no
    pulseaudio daemon running, as long as you have pipewire-pulse installed.
  - Use wpctl as the Pipewire way of manipulating the audio environment.
  - To get ~tts_left~ and ~ tts_right~ devices for Emacspeak, execute
    the corresponding pactl commands by hand at the shell for now, ie
    examine default.pa from the pulseaudio lines, then pass them to
    pactl.

    
#+begin_src 
# A bs2b (binaural for headphones) sink:
pactl load-module module-ladspa-sink sink_name=binaural  sink_master=@DEFAULT_SINK@ plugin=bs2b label=bs2b control=725,4.5
# Use binaural as the default sink:
pactl #set-default-sink  binaural 
# A tts_right and tts_left device
# Emacspeak will use the first as the notification device.
pactl load-module module-remap-sink sink_name=tts_right  master=binaural channels=2 master_channel_map=front-right,front-right, channel_map=front-left,front-right remix=no
pactl load-module module-remap-sink sink_name=tts_left  master=binaural channels=2 master_channel_map=front-left,front-left, channel_map=front-left,front-right remix=no
#+end_src

#+begin_src 
#hrtf example:


pactl load-module module-ladspa-sink sink_name=upper plugin=ZamHeadX2-ladspa label=ZamHeadX2 control=45,45,2.5 
#+end_src


*Bridge  setup

Here, /Bridge/ stands for crossing over to the world of Pipewire  from
the world of Pulseaudio.
Landing completely on pipewire makes things a lot simpler, see next
section.

1. Execute ~./pa2pw.sh~ after reboot to get ~tts_left~,~tts_right~ and a ~binaural~ device.
2. Execute ~./pw-hrtf.sh~ to get 8 virtual HRTF devices.

* Final Landing

  - Install package ~pipewire-alsa~ and ~pipewire-audio~.
  - This removes pulseaudio from the system.
  - X11 Bell (auditory icon) is back.
  - The original ~.asoundrc~ that I used for nearly 15+ years works again!
  - I suspect eventually that too will get simplified as ~wireplumber~
    matures, but that day is not yet come.
    

#+options: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+options: author:t broken-links:nil c:nil creator:nil
#+options: d:(not "LOGBOOK") date:t e:t email:nil f:t inline:t num:t
#+options: p:nil pri:nil prop:nil stat:t tags:t tasks:t tex:t
#+options: timestamp:t title:t toc:nil todo:t |:t
#+title: Notes On Migrating To Pipewire From Pulseaudio
#+date: <2023-10-26 Thu>
#+author: T.V Raman
#+email: raman@google.com
#+language: en
#+select_tags: export
#+exclude_tags: noexport
#+creator: Emacs 30.0.50 (Org mode 9.6.9)
#+cite_export:
