boehm.sh/content/posts/setup-lookback-audio-device-pipewire.md
2024-07-13 23:47:30 +02:00

3.9 KiB

+++ title = 'Setting Up a Loopback Audio Device with Pipewire' description = 'Learn how to set up a loopback audio device using Pipewire. Follow our step-by-step guide for seamless audio routing and recording.' date = 2024-07-13T07:07:07+01:00 draft = false categories = [ "Audio Configuration", "Linux", "Pipewire"] tags = ["Loopback Audio", "Pipewire Setup", "Focusrite Scarlett 2i2", "Linux Sound System", "Audio Routing", "Recording Audio", "Audio Interface Configuration"] +++

Creating a loopback audio device in Pipewire can be useful for routing audio between different applications or capturing audio from one application to another. This guide will walk you through the steps to set up a loopback device for your Focusrite Scarlett 2i2 audio interface.

Prerequisites

Ensure you have Pipewire installed and running on your system. This guide assumes you are familiar with basic terminal commands and have access to edit configuration files.

Step-by-Step Instructions

  1. Identify the Target Output Device

    First, you need to identify the name of the target output device for your audio interface. Run the following command to list all audio nodes:

    pw-dump | grep "node.name"
    

    Look for the output node of your audio interface. For the Focusrite Scarlett 2i2, it might look something like
    alsa_output.usb-Focusrite_Scarlett_2i2_USB-00.pro-output-0.

  2. Create the Configuration File

    Next, create a new configuration file for the loopback module. This file should be placed in ~/.config/pipewire/pipewire.conf.d/. You might need to create the directory if it does not exist:

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

    Then, create and open the configuration file:

    vim ~/.config/pipewire/pipewire.conf.d/90-loopback.conf
    
  3. Add the Loopback Configuration

    Copy and paste the following configuration into the file. Adjust the parameters as needed to match your setup:

    context.modules = [
        {
            name = libpipewire-module-loopback
            args = {
                node.description = "Scarlett 2i2 Loopback"
                capture.props = {
                    node.name = "Scarlett_2i2_Loopback"
                    media.class = "Audio/Sink"
                    audio.position = [ FL FR ]
                }
                playback.props = {
                    node.name = "playback.Scarlett_2i2_Loopback"
                    audio.position = [ AUX0 AUX1 ]
                    target.object = "alsa_output.usb-Focusrite_Scarlett_2i2_USB-00.pro-output-0"
                    stream.dont-remix = true
                    node.dont-reconnect = false
                    node.passive = true
                }
            }
        }
    ]
    
    • node.description: A descriptive name for your loopback device.
    • node.name: An identifier for the node. Ensure it starts with playback. for playback properties. This should match the node.name of capture.props.
    • target.object: The output node you identified earlier.
  4. Restart Pipewire

    After saving the configuration file, restart Pipewire to apply the changes:

    systemctl --user restart pipewire
    

Additional Notes

  • node.description: You can change this to a name that best describes its purpose, such as "Scarlett 2i2 Loopback for Recording".
  • node.name: This should be a unique identifier without spaces. For playback nodes, it should start with playback.. This should match the node.name of capture.props.
  • target.object: Ensure you are using the correct output node for your audio interface. If your device has both input and output nodes, make sure to select the output node.

By following these steps, you should have a loopback audio device set up with Pipewire, allowing you to route audio from your Scarlett 2i2 audio interface for various purposes like recording or live streaming.