- ONLY AUDIO BY NOW [PR & FR WELCOME]
- STREAMING NOT SUPPORTED BY NOW
Python controller, player and recorder via pipewire's commands.
- Pipewire is a project that aims to greatly improve handling of audio and video under Linux. (Better than pulseaudio or jack)
A Pipewire version installed (clean or via Pulseaudio) is needed, to check if you have pipewire installed and running, run this command, if the output is different, you'll need to install pipewire:
- Pipewire versions supported: 0.3.30, 0.3.32+
pw-cli info 0# Example output
id: 0
permissions: rwxm
type: PipeWire:Interface:Core/3
cookie: 134115873
user-name: "user"
host-name: "user"
version: "0.3.30"# Possibly more actual than this version
name: "pipewire-0"
...To uninstall pipewire click here.
- Python 3.7+
- Ubuntu 20.04+
pip3 install pipewire_python # or pipfrompipewire_python.controllerimportController# [PLAYBACK]: normal wayaudio_controller=Controller()
audio_controller.set_config(rate=384000,
channels=2,
_format='f64',
volume=0.98,
quality=4)
audio_controller.playback(audio_filename='docs/beers.wav')
# [RECORD]: normal wayaudio_controller=Controller()
audio_controller.record(audio_filename='docs/5sec_record.wav',
timeout_seconds=5)frompipewire_python.controllerimportControlleraudio_controller=Controller()
# Return all Client Interfaces on Pipewireaudio_controller.get_list_interfaces(
type_interfaces="Client",
filtered_by_type=True,
)
# Return all interfacesaudio_controller.get_list_interfaces(
filtered_by_type=False,
)frompipewire_pythonimportlinkinputs=link.list_inputs()
outputs=link.list_outputs()
# Connect the last output to the last input -- during testing it was found that# Midi channel is normally listed first, so this avoids that.source=outputs[-1]
sink=inputs[-1]
source.connect(sink)
# Fun Fact! You can connect/disconnect in either order!sink.disconnect(source) # Tada!# Default Input/Output links will be made with left-left and right-right# connections; in other words, a straight stereo connection.# It's possible to manually cross the lines, however!source.right.connect(sink.left)
source.left.connect(sink.right)You can check the automatic build documentation HERE
Future implementations, next steps, API implementation and Control over Pipewire directly from python in the ROADMAP.
PR, FR, and issues are welcome. Changes with PR in dev branch please due documentation runs after each commit in main branch. Check more here