Last active
November 24, 2021 10:52
-
-
Save dali99/15dbc36c597818ce64b70f716c8791e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#!nix-shell -i bash -p bash pulseaudio jalv pipewire tmux | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Variables | |
outL="alsa_output.usb-Conexant_CONEXANT_USB_AUDIO_000000000000-00.analog-stereo:playback_FL" | |
outR="alsa_output.usb-Conexant_CONEXANT_USB_AUDIO_000000000000-00.analog-stereo:playback_FR" | |
inM="alsa_input.usb-Conexant_CONEXANT_USB_AUDIO_000000000000-00.mono-fallback:capture_MONO" | |
# Tmux session for jalv audio-plugins | |
tmux new-session -d -s "audio-session" || true | |
# Virtual audio out device for headset | |
pw-cli create-node adapter \ | |
'{ factory.name=support.null-audio-sink node.name=VirtualHeadset media.class=Audio/Sink object.linger=1 audio.position=[FL,FR] }' | |
pw-metadata 0 default.configured.audio.sink '{ "name": "VirtualHeadset" }' | |
echo "Loaded VirtualHeadset" | |
# Equalizer for Headset | |
tmux new-window -t "audio-session" -n "EQ" \ | |
jalv -l "$HOME/audio configs/impulse-response" "http://lsp-plug.in/plugins/lv2/impulse_responses_stereo" | |
echo "Started Equalizer" | |
sleep 1 | |
pw-link VirtualHeadset:monitor_FL "LSP Impulse Responses Stereo:in_l" | |
pw-link VirtualHeadset:monitor_FR "LSP Impulse Responses Stereo:in_r" | |
echo "Linked Equalizer" | |
# Set volume of VirtualHeadset (-4.8dB) for preamp effect | |
# Replace with actual preamp? | |
pactl -- set-sink-volume VirtualHeadset 83% | |
# Connect last of chain to actual headset | |
pw-link "LSP Impulse Responses Stereo:out_l" $outL | |
pw-link "LSP Impulse Responses Stereo:out_r" $outR | |
echo "Linked Real Headset" | |
# Microphone | |
# Create VMic and set as default | |
pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=VirtualMic channel_map=front-left,front-right | |
pactl set-default-source VirtualMic | |
echo "Loaded Virtual Microphone" | |
# Start Noise Gate (Activity Activated) | |
tmux new-window -t "audio-session" -n "noise-gate" \ | |
jalv -l "$HOME/audio configs/noise-gate" "http://lsp-plug.in/plugins/lv2/gate_mono" | |
echo "Started Noise Gate" | |
sleep 1 | |
pw-link $inM "LSP Gate Mono:in" | |
echo "Linked Real Microphone to Noise Gate" | |
tmux new-window -t "audio-session" -n "noise-gate" \ | |
jalv -l "audio configs/denoiser" "https://github.com/lucianodato/speech-denoiser" | |
echo "Created Speech denoiser (rnn)" | |
sleep 2 | |
pw-link "LSP Gate Mono:out" "Speech Denoiser:input" | |
echo "Linked Noise Gate to Speech Denoiser" | |
sleep 1 | |
pw-link "Speech Denoiser:output" "VirtualMic:input_FL" | |
pw-link "Speech Denoiser:output" "VirtualMic:input_FR" | |
echo "Connected Speech Denoiser to VirtualMic" | |
# Output audio to virtualMic | |
pactl load-module module-null-sink media.class=Audio/Sink sink_name=SendToVirtualMic channel_map=front-left,front-right | |
echo "Loaded Virtual Microphone Sink" | |
sleep 1 | |
pw-link "SendToVirtualMic:monitor_FL" "VirtualMic:input_FL" | |
pw-link "SendToVirtualMic:monitor_FR" "VirtualMic:input_FR" | |
echo "Linked SendToVirtualMic to VirtualMic" | |
pw-link "SendToVirtualMic:monitor_FL" "VirtualHeadset:playback_FL" | |
pw-link "SendToVirtualMic:monitor_FR" "VirtualHeadset:playback_FR" | |
echo "Linked SendToVirtualMic to VirtualHeadset" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment