Skip to main content

A simple CLI script to setup PulseAudio loopbacks

Project description

pulseaudio-simple-loopback

A simple Python CLI tool for quickly setting up and tearing down PulseAudio loopback modules — ideal for routing audio between input and output devices like USB interfaces, Bluetooth headsets, and virtual sinks.

Developed because I coudn't be bothered to set it up manually every time I wanted to play on my Korg synthesizer ʅ ( ․ ⤙ ․) ʃ.

It provides two terminal commands:

  • loopback-setup: Interactively sets up PulseAudio loopback between a selected input and output.
  • loopback-stop: Unloads all loaded loopback modules.

Installation

Option 1: Install from PyPI (Recommended)

pip install pulseaudio-simple-loopback

Installs the loopback-setup and loopback-stop commands system-wide.

Option 2: Install from source

git clone https://github.com/YOUR_USERNAME/pulseaudio-simple-loopback.git
cd pulseaudio-simple-loopback
pip install .

Usage Example

loopback-setup

This command walks you through selecting a source and sink from your available PulseAudio devices, and then creates a loopback between them.

❯ loopback-setup
                                 Available Sources                                  
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Index ┃ Name                                                                     ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│     0 │ alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo-input │
│     1 │ bluez_input.14:3F:A6:F2:83:9D                                            │
└───────┴──────────────────────────────────────────────────────────────────────────┘
Select audio source index: 0
                                   Available Sinks                                    
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Index ┃ Name                                                                       ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│     0 │ alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo-output │
│     1 │ bluez_output.14_3F_A6_F2_83_9D.1                                           │
└───────┴────────────────────────────────────────────────────────────────────────────┘
Select audio sink index: 1

Setting loopback from: alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo-input to bluez_output.14_3F_A6_F2_83_9D.1
Loopback module ID: 536870918
Loopback enabled successfully

In some cases with Bluetooth output devices (for ex. Sony WH-1000XM4), PulseAudio may not activate the loopback immediately.

Hence, when a Bluetooth sink is selected, the script offers to quickly disconnect and reconnect the device — which usually helps:

Detected Bluetooth sink: bluez_output.14_3F_A6_F2_83_9D.1, MAC: 14:3F:A6:F2:83:9D
The script detected you've selected a Bluetooth device as the loopback sink.
In some instances, the device needs to be disconnected and reconnected if the loopback doesn't start properly.
Do you want to disconnect and reconnect your Bluetooth device now? [y/n]:

loopback-stop

This command unloads all detected loopback modules:

❯ loopback-stop
Unloading module-loopback ID 536870918...
Unloaded 1 loopback module(s)

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pulseaudio_simple_loopback-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pulseaudio_simple_loopback-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pulseaudio_simple_loopback-1.0.0.tar.gz.

File metadata

File hashes

Hashes for pulseaudio_simple_loopback-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b136b3d19a6911dde0b037ac638e0c5aaab0940726b0cf63a3ea92e49d5a75c9
MD5 8b5704c50f4af1454ff2a62eec196667
BLAKE2b-256 6ab97173ded30a8b48e474230ca48e978684d8d4bee1212257665886544b3868

See more details on using hashes here.

File details

Details for the file pulseaudio_simple_loopback-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pulseaudio_simple_loopback-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18ffc4d29c9f82c00a4b08284b378cbc056b98dea3d5a748f02d64747675bc06
MD5 f7641255807642e2ec2cb5e06f2b0848
BLAKE2b-256 0de531a87dec28328d77fe25cc040500eff15a4ba74f2e5b282dc523e8722cf6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page