Last active
November 13, 2016 09:38
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on http://amiexp.blogspot.it/2013/01/respberry-pi-with-shairport-and-usb.html, https://jeffskinnerbox.wordpress.com/2012/11/15/getting-audio-out-working-on-the-raspberry-pi/, http://lifehacker.com/5978594/turn-a-raspberry-pi-into-an-airplay-receiver-for-streaming-music-in-your-living-room