Skip to content

Instantly share code, notes, and snippets.

@mmdbalkhi
Created May 9, 2022 17:37
Show Gist options
  • Select an option

  • Save mmdbalkhi/d3f99c7fc1899945c736601eabb07008 to your computer and use it in GitHub Desktop.

Select an option

Save mmdbalkhi/d3f99c7fc1899945c736601eabb07008 to your computer and use it in GitHub Desktop.
stream sounds with pulseaudio
#!/bin/sh
ip=`ip addr show | grep -oP '(?<=inet\s)(192\.)+\d+(\.\d+){2}'`
rate=48000
channels=2
port=1234
case "$1" in
start)
echo "* ip: $ip"
echo "* port: $port"
echo "* channel(s): $channels"
echo "* rate: $rate"
$0 stop
printf "\n* pactl:"
pactl load-module module-simple-protocol-tcp rate=$rate format=s16le channels=$channels source=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor record=true port=$port
;;
stop)
pactl unload-module `pactl list | grep tcp -B1 | grep M | sed 's/[^0-9]//g'`
;;
*)
echo "Usage: $0 start|stop" >&2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment