目标
构建一个可编程控制的流媒体播放服务器,类似于智能音箱,但是没有麦克风收集个人隐私数据。
整体架构如下
graph LR
subgraph 树莓派 Raspberry Pi
A[cmus音乐播放器] --> B(PulseAudio Client)
end
subgraph VoCore
C(PulseAudio Server) --> D[音响 / 扬声器]
end
B --> C
Vocore固件支持
Currently 2022/12/3, only openwrt 21.02 is supported. (patch is not working ins 22.03)
see https://github.com/Vonger/vocore2
Because audio is enabled by kmod+ packages, so I need to build the firmware myself.
Alsa
install alsa-utils packages, then add configuration to init sound card
in /etc/rc.local file
alsactl init
Adjust volume
use
alsamixeruse
amixer
https://downloads.openwrt.org/releases/23.05.5/targets/ramips/mt76x8/packages
# list devices
amixer scontrols
amixer sset 'PCM' 50%
amixer sset 'Output 1' 50%
test audio
use madplay to play sounds
madplay -A -5 -r /tmp/5314e49717753082b203497887a7a7ec_5512980116828022124.mp3
PulseAudio
install Avahi/ZeroConf as pulseaudio server
opkg install pulseaudio-daemon-avahi
configure network access
# /etc/pulse/system.pa
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.50.0/24;192.168.61.0/24
load-module module-zeroconf-publish
enhance low resources
# /etc/pulse/daemon.conf
high-priority = yes
nice-level = -11
realtime-scheduling = yes
resample-method = trivial
default-sample-format = s16le
default-sample-rate = 48000
default-sample-channels = 2
default-channel-map = front-left,front-right
test in client devices
export PULSE_SERVER=tcp:REMOTE_SERVER_IP
then run madplay to play sounds
how to connect by default
edit ~/.config/pulse/client.conf
default-server = tcp:REMOTE_SERVER_IP
# (可选)如果本地PulseAudio不断尝试启动并干扰连接,添加此行
# autospawn = no