pw-loopback Command Examples in Linux

In PipeWire, loopback devices allow users to capture audio from one source and play it back on another source. This can be useful for a variety of applications, such as recording audio from an application and playing it back through speakers, or routing audio from one application to another.

The pw-loopback tool is used to create loopback devices in PipeWire. Loopback devices are virtual audio sources and sinks that allow audio to be captured and played back in real-time.

To create a loopback device using pw-loopback, users need to specify the source and sink ports using their port IDs. Port IDs can be obtained using the pw-cli tool or other PipeWire tools. Once the source and sink ports are specified, users can use pw-loopback to create a loopback device between them.

pw-loopback Command Examples

1. Create a loopback device with the default loopback behavior:

# pw-loopback

2. Create a loopback device that automatically connects to the speakers:

# pw-loopback -m '{{[FL FR]}}' --captureprops='{{media.class=Audio/Sink}}'

3. Create a loopback device that automatically connects to the microphone:

# pw-loopback -m '{{[FL FR]}}' --playbackprops='{{media.class=Audio/Source}}'

4. Create a dummy loopback device that doesn’t automatically connect to anything:

# pw-loopback -m '{{[FL FR]}}' --captureprops='{{media.class=Audio/Sink}}' --playbackprops='{{media.class=Audio/Source}}'

5. Create a loopback device that automatically connects to the speakers and swaps the left and right channels between the sink and source:

# pw-loopback --capture-props='{{media.class=Audio/Sink audio.position=[FL FR]}}' --playbackprops='{{audio.position=[FR FL]}}'

6. Create a loopback device that automatically connects to the microphone and swaps the left and right channels between the sink and source:

# pw-loopback --capture-props='{{audio.position=[FR FL]}}' --
playback-props='{{media.class=Audio/Source audio.position=[FLFR]}}'

Summary

Overall, pw-loopback is a powerful tool for creating loopback devices in PipeWire, allowing users to capture and play back audio in real-time. More information about virtual devices and how to use them can be found in the PipeWire documentation.

Related Post