## Overview

This guide creates a processed microphone input with WebRTC noise suppression, gain control and high-pass filtering.

The created input is named automatically:

- `Detachable Microphone` on StarFighter systems.
- `Internal Microphone` on other Star Labs systems.

## Before you start

Set your audio input to the built-in microphone before running the command below.

The command sets the real microphone path to 30%, then creates the processed microphone on top of it. After that, control input level using the new processed microphone.

## Step 1: Open Terminal

- Press `Ctrl` + `Alt` + `T`

## Step 2: Create the processed microphone

Copy/paste this whole block into Terminal:

```bash
TARGET_SOURCE="$(wpctl inspect @DEFAULT_AUDIO_SOURCE@ | awk -F'= ' '/node.name =/{gsub(/"/,"",$2); print $2; exit}')"
RAW_SKU="$(cat /sys/class/dmi/id/product_sku 2>/dev/null || true)"

case "$RAW_SKU" in
  F1|F1-A|F2)
    MIC_NAME="Detachable Microphone"
    ;;
  *)
    MIC_NAME="Internal Microphone"
    ;;
esac

if [ -z "$TARGET_SOURCE" ]; then
  echo "Could not find the current audio input. Please select the built-in microphone and try again."
  exit 1
fi

# Keep the real microphone input low enough to avoid clipping/noise.
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 30%

mkdir -p ~/.config/pipewire/pipewire.conf.d

cat > ~/.config/pipewire/pipewire.conf.d/99-starlabs-mic-processing.conf <<EOF
context.modules = [
    { name = libpipewire-module-echo-cancel
        flags = [ ifexists nofail ]
        args = {
            aec.method = webrtc
            aec.args = {
                noise_suppression = true
                gain_control = true
                high_pass_filter = true
            }

            source.props = {
                node.name = "starlabs_mic_processed"
                node.description = "$MIC_NAME"
                media.class = "Audio/Source"
            }

            capture.props = {
                node.name = "starlabs_mic_capture"
                target.object = "$TARGET_SOURCE"
            }

            sink.props = {
                node.name = "starlabs_mic_sink"
                node.description = "$MIC_NAME Sink"
                media.class = "Audio/Sink"
            }

            playback.props = {
                node.name = "starlabs_mic_playback"
            }
        }
    }
]
EOF
```

## Step 3: Restart audio services

Copy/paste:

```bash
systemctl --user restart pipewire pipewire-pulse wireplumber
```

Wait 5–10 seconds.

If this command reports that one of the services does not exist, reboot instead:

```bash
sudo reboot
```

## Step 4: Select the processed microphone

Open **Settings → Sound → Input**, then select:

- `Detachable Microphone` on StarFighter systems.
- `Internal Microphone` on other systems.

## Important: Some apps pick their own microphone

Apps like **Zoom**, **Microsoft Teams**, and **Google Meet** may have a mic selector inside the app.

If it still sounds wrong in the app, open the app’s **Audio / Microphone** settings and select the processed microphone there too.

## Terminal fallback: set it as default with `wpctl`

### Step A: Find the device ID

Run:

```bash
wpctl status
```

Look under **Sources** for `Detachable Microphone` or `Internal Microphone`, then note the **ID number**.

### Step B: Set it as the default microphone

Replace `<ID>` with the number you found:

```bash
wpctl set-default <ID>
```

## Troubleshooting

### I don’t see the processed microphone in Settings

1. Restart services again:

```bash
systemctl --user restart pipewire pipewire-pulse wireplumber
```

2. Confirm the config file exists:

```bash
ls -l ~/.config/pipewire/pipewire.conf.d/99-starlabs-mic-processing.conf
```

If that file is missing, the processed microphone won’t appear.

### My microphone is still too loud or distorted

Make sure the original microphone input is set to 30%:

```bash
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 30%
```

Then keep using the processed microphone as the selected input.
