PulseAudio

From Vague Hope Wiki
Jump to: navigation, search

General

Install:

sudo aptitude install pulseaudio pulseaudio-utils pavucontrol

Control:

pacmd
pacmd help
pacmd list-modules
pacmd list-sinks
pacmd load-module module-tunnel-sink server=192.168.0.211
pacmd load-module module-combine sink_name=combined slaves="alsa_output.pci-0000_00_1b.0.analog-surround-40,tunnel-sink.192.168.0.211"
pacmd unload-module <number from list-modules>

Restart:

pulseaudio -k
speaker-test -c2

Move:

pacmd list-sinks
pacmd list-sink-inputs
pacmd move-sink-input <x> <y>

Volume:

bash -c 'pactl -- set-sink-volume `pacmd list-sinks | grep -P -o "(?<=\* index: )[0-9]+"` -10%'

Loopback:

pacmd load-module module-loopback source=alsa_input.pci-0000_00_1b.0.analog-stereo

http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index62h3

Streaming

RTP/MP3/Multicast

Broadcast:

apti libavcodec-extra-53
pacmd load-module module-rtp-send source=@DEFAULT_MONITOR@ destination=127.0.0.1 port=46998 loop=1
cvlc rtp://@127.0.0.1:46998 ":sout=#transcode{acodec=mp3,ab=256,channels=2}:duplicate{dst=rtp{dst=225.0.0.1,mux=ts,port=12345}}"

Receive:

cvlc rtp://@225.0.0.1:12345

Testing receive (may need to change addr:port):

mplayer -cache 2048 -demuxer rawaudio -rawaudio format=0x20776172 rtp://224.0.0.56:46416

RTP/MP3/Unicast

Send:

pacmd load-module module-rtp-send source=@DEFAULT_MONITOR@ destination=127.0.0.1 port=46998 loop=1
cvlc rtp://@127.0.0.1:46998 ":sout=#transcode{acodec=mp3,ab=192,channels=2}:duplicate{dst=rtp{dst=192.168.0.211,mux=ts,port=12345,rtcp-mux=true}}"

Receive:

cvlc rtp://192.168.0.211:12345

HTTP/Ogg

Broadcast:

apti libavcodec-extra-53
pacmd load-module module-rtp-send source=@DEFAULT_MONITOR@ destination=127.0.0.1 port=46998 loop=1
cvlc rtp://@127.0.0.1:46998 ':sout=#transcode{acodec=vorb,ab=128}:standard{access=http,mux=ogg,dst=0.0.0.0:13131}'

Receive:

cvlc http://192.168.0.4:13131

Service

/etc/default/pulseaudio

PULSEAUDIO_SYSTEM_START=1
DISALLOW_MODULE_LOADING=0
sudo usermod pi -a -G pulse-access

And reboot.

pacmd

When running as shared service (http://pulseaudio.org/ticket/222):

bin/shared-pacmd

#!/bin/bash
if [ "$USER" == "pulse" ] ; then
  export PULSE_RUNTIME_PATH=/var/run/pulse
  pacmd
else
  sudo -u pulse "$0"
fi

References