Setup Home WiFi Audio System

Build home MPD wifi audio system, by combine:

  • Active Speaker
  • Wifi Router with usb port, and support openwrt
  • USB sound card

Upgrade openwrt to the latest version

SSH log into openwrt

######################################
######### Repository #################

cp /etc/opkg/distfeeds.conf  /etc/opkg/distfeeds.conf.bak
sed -i "s#downloads.openwrt.org#mirrors.ustc.edu.cn/openwrt#g" /etc/opkg/distfeeds.conf
#sed -i "s#downloads.openwrt.org#mirrors.tuna.tsinghua.edu.cn/openwrt#g" /etc/opkg/distfeeds.conf
#sed -i "s#downloads.openwrt.org#mirrors.aliyun.com/openwrt#g" /etc/opkg/distfeeds.conf
#sed -i "s#downloads.openwrt.org#mirrors.cloud.tencent.com/openwrt#g" /etc/opkg/distfeeds.conf

opkg update


######################################
########## pulseaudio ################

opkg install kmod-input-core
opkg install kmod-sound-core
opkg install kmod-usb-audio
opkg install pulseaudio-daemon


#########################################
########## Sound Blaster ################
# opkg install kmod-ac97
# opkg install kmod-sound-ens1371


########## AC 97 ########################
#opkg install kmod-sound-cs5535audio 


####### Motherboard Sound Card ##########
#opkg install  kmod-sound-i8x0

############ Soc Sound Card #############
#opkg install  kmod-sound-soc-core 



##### Editor ############################ 
# opkg install nano


###########  Utility  ###################
#opkg install usbutils
#opkg install alsa-utils


### Allow module load ###
sed -i "s/--disallow-module-loading//"   /etc/init.d/pulseaudio

### Load TCP module ###
sed -i "s/load-module module-native-protocol-unix/load-module module-native-protocol-tcp auth-anonymous=1/"  /etc/pulse/system.pa





### Firewall ###
sh -c " cat >/etc/config/firewall " << EOF


######  ssh port ##################
config redirect
       option src              wan
       option src_dport        22
       option dest             lan
       option dest_ip          192.168.1.1
       option dest_port        22
       option proto            tcp

###### pulseaudio port ############
config redirect
       option src              wan
       option src_dport        4713
       option dest             lan
       option dest_ip          192.168.1.1
       option dest_port        4713
       option proto            tcp

###### Http Port ##################
onfig redirect
        option src 'wan'
        option src_dport '80'
        option dest 'lan'
        option dest_ip '192.168.1.1'
        option dest_port '80'
        option proto 'tcp'

EOF



/etc/init.d/firewall   restart
/etc/init.d/pulseaudio restart




######################################
######################################
########## WiFI Relay ################
opkg install relayd
opkg install luci-proto-relay


# From web admin portal, setup new wireless wan port for 5G and 2G separately:
# http://192.168.1.1/cgi-bin/luci/
### Network
### Wireless
### Scan
### Selected your existed SSID, Joining Network
### ## Replace wireless configuration  = yes
### ## Create / Assign firewall-zone   = LAN
### Go to Network/Interface
### Set the IP of  wireless wan, as normal

Login into your MPD system, add the following block into the the mpd.conf file:

audio_output {

 type "pulse"

 name " Wifi Router"

 server "IP_OF_WIFI_ROUTER:4713" 

}

Now, you can find the “Wifi Router” option item, from Outputs/Server properties/M.A.L.P, suppose M.A.L.P apk installed android handset