Skip to content

Instantly share code, notes, and snippets.

@andrearota
Last active November 13, 2016 09:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrearota/d4e1634fcd377da99369 to your computer and use it in GitHub Desktop.
Save andrearota/d4e1634fcd377da99369 to your computer and use it in GitHub Desktop.
Shairport and alsa configuration to make a Raspberry Pi able to receive AirPlay sound streams, equalize the sound with ALSA equal plugin and play them either on HDMI audio interface or Raspberry PWM analog output
# File: /etc/asound.conf
# .alsaequal.bin is automatically created tuning the equalizer with "alsamixer -D equal"
ctl.equal {
type equal;
controls "/home/pi/.alsaequal.bin"
}
pcm.plugequal {
type equal;
# Change plughw:0,0 accordingly with the physical audio device (type "alsa -L" for a list of devices availables). On Raspberry Pi, the card 0 internal audio DAC, both on HDMI digital mode and PWM analog audio (launch "amixer cset numid=3 2" to enable HDMI audio, "amixer cset numid=3 1" to switch to analog)
slave.pcm "plughw:0,0";
controls "/home/pi/.alsaequal.bin"
}
pcm.equal {
type plug;
slave.pcm plugequal;
}
#!/bin/bash
#
# File: /etc/init.d/shairport
# This starts and stops shairport on Raspberry, using the libasound2-plugin-equal as output ALSA device.
#
### BEGIN INIT INFO
# Provides: shairport
# Required-Start: $network
# Required-Stop:
# Short-Description: shairport - Airtunes emulator!
# Description: Airtunes emulator!
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Source function library.
. /lib/lsb/init-functions
NAME=shairport
AODEV="equal"
DAEMON="/usr/local/bin/shairport.pl"
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="-w $PIDFILE -a RaspberryPi --ao_devicename=$AODEV"
[ -x $binary ] || exit 0
RETVAL=0
start() {
echo -n "Starting shairport: "
start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
--exec "$DAEMON" -b --oknodo -- $DAEMON_ARGS
log_end_msg $?
}
stop() {
echo -n "Shutting down shairport: "
start-stop-daemon --stop --quiet --pidfile "$PIDFILE" \
--retry 1 --oknodo
log_end_msg $?
}
restart() {
stop
sleep 1
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status shairport
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
;;
esac
exit 0