From e57cfd8f81742b9ff3b45a8417e4e8c57d52490b Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 19 Sep 2024 23:45:46 +0200 Subject: [PATCH] add gst and pw connections scripts with and without jack --- tests/tc_audio_pw.sh | 2 +- tests/tc_audio_pw_jack.sh | 18 ++++++++++++ tests/tc_audio_pw_nojack.sh | 18 ++++++++++++ tests/tc_link_pw.py | 57 +++++++++++++++++++++++++++++++++++++ tests/tc_link_pw_jack.py | 49 +++++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tests/tc_audio_pw_jack.sh create mode 100644 tests/tc_audio_pw_nojack.sh create mode 100644 tests/tc_link_pw.py create mode 100644 tests/tc_link_pw_jack.py diff --git a/tests/tc_audio_pw.sh b/tests/tc_audio_pw.sh index a07fe8a..24ca397 100755 --- a/tests/tc_audio_pw.sh +++ b/tests/tc_audio_pw.sh @@ -6,7 +6,7 @@ set -e source /etc/telecaster/telecaster.conf -gst-launch-1.0 pipewiresrc client-name="audio_processing" target-object="jack_source" ! audio/x-raw, format=F32LE, channels=$AUDIO_CHANNELS \ +gst-launch-1.0 pipewiresrc client-name="audio_processing" ! audio/x-raw, format=F32LE, channels=$AUDIO_CHANNELS \ ! queue ! audioconvert \ ! queue ! audiocheblimit mode=high-pass cutoff=120 poles=4 \ ! queue ! volume volume=$AUDIO_GAIN_PRE \ diff --git a/tests/tc_audio_pw_jack.sh b/tests/tc_audio_pw_jack.sh new file mode 100644 index 0000000..b7b9427 --- /dev/null +++ b/tests/tc_audio_pw_jack.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +# Default TeleCaster video parameters + +source /etc/telecaster/telecaster.conf + +gst-launch-1.0 pipewiresrc client-name="audio_processing" ! audio/x-raw, format=F32LE, channels=$AUDIO_CHANNELS \ + ! queue ! audioconvert \ + ! queue ! audiocheblimit mode=high-pass cutoff=120 poles=4 \ + ! queue ! volume volume=$AUDIO_GAIN_PRE \ + ! queue ! audiodynamic characteristics=soft-knee mode=compressor threshold=0.125 ratio=0.125 \ + ! queue ! volume volume=$AUDIO_GAIN_POST \ + ! queue ! audiodynamic characteristics=hard-knee mode=compressor threshold=0.95 ratio=0.001 \ + ! queue ! pipewiresink client-name="audio_processing" + + diff --git a/tests/tc_audio_pw_nojack.sh b/tests/tc_audio_pw_nojack.sh new file mode 100644 index 0000000..b7b9427 --- /dev/null +++ b/tests/tc_audio_pw_nojack.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +# Default TeleCaster video parameters + +source /etc/telecaster/telecaster.conf + +gst-launch-1.0 pipewiresrc client-name="audio_processing" ! audio/x-raw, format=F32LE, channels=$AUDIO_CHANNELS \ + ! queue ! audioconvert \ + ! queue ! audiocheblimit mode=high-pass cutoff=120 poles=4 \ + ! queue ! volume volume=$AUDIO_GAIN_PRE \ + ! queue ! audiodynamic characteristics=soft-knee mode=compressor threshold=0.125 ratio=0.125 \ + ! queue ! volume volume=$AUDIO_GAIN_POST \ + ! queue ! audiodynamic characteristics=hard-knee mode=compressor threshold=0.95 ratio=0.001 \ + ! queue ! pipewiresink client-name="audio_processing" + + diff --git a/tests/tc_link_pw.py b/tests/tc_link_pw.py new file mode 100644 index 0000000..bddb5c9 --- /dev/null +++ b/tests/tc_link_pw.py @@ -0,0 +1,57 @@ +#!/usr/bin/python3 + +from pipewire_python import link + + +def find_object(puts, device): + for put in puts: + if hasattr(put, "left"): + p = put.left + if device in p.device and hasattr(p, "port_type"): + if not "monitor" in p.name: + return put + else: + if device in put.device and hasattr(put, "port_type"): + return put + +inputs = link.list_inputs() +outputs = link.list_outputs() + +# print(inputs) +# print(outputs) + +firefox_input = find_object(inputs, "Firefox") +audio_processing_output = find_object(outputs, "audio_processing") +audio_processing_input = find_object(inputs, "audio_processing") +alsa_output = find_object(outputs, "alsa_input.pci-0000") +alsa_input = find_object(inputs, "alsa_output.pci-0000") +mic_output = find_object(outputs, "Mic1") + +# print(alsa_output) +# print(alsa_inputs) +# print(firefox) +# print(audio_processing_input) + +alsa_output.disconnect(audio_processing_input) + +# mono source +mic_output.connect(audio_processing_input.left) +mic_output.connect(audio_processing_input.right) + +firefox_input.connect(audio_processing_output) +firefox_input.disconnect(alsa_output) + +# 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) diff --git a/tests/tc_link_pw_jack.py b/tests/tc_link_pw_jack.py new file mode 100644 index 0000000..b70f63a --- /dev/null +++ b/tests/tc_link_pw_jack.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +from pipewire_python import link + + +def find_object(puts, device): + for put in puts: + if hasattr(put, "left"): + p = put.left + if device in p.device: + if not "monitor" in p.name: + return put + else: + if device in put.device: + return put + +inputs = link.list_inputs() +outputs = link.list_outputs() + +# print(inputs) +# print(outputs) + +firefox = find_object(inputs, "Firefox") +audio_processing = find_object(outputs, "audio_processing") +jack_source = find_object(outputs, "jack_source") +alsa_inputs = find_object(inputs, "alsa") + +# print(alsa_inputs) +# print(firefox) +# print(audio_processing) + +firefox.connect(audio_processing) +jack_source.disconnect(firefox) +audio_processing.disconnect(alsa_inputs) + +# 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) -- 2.39.5