-
Notifications
You must be signed in to change notification settings - Fork 3
System setup @ petli
Actual stuff:
- RaspberryPi B with 5.25V 2A power supply
- Cambridge Audio DacMagic (0d8c:000c C-Media Electronics, Inc. Audio Adapter)
- SATA Bluray reader
- USB-SATA adapter with external power
- Wifi USB dongle with external antenna (148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter)
- A small wireless USB mouse (as remote control)
- USB-hub, 4 ports, no external power
Conceptual setup:
The DAC is connected to one of the two onboard USB ports of the RPi. The DVD and the wifi dongle are connected to the USB hub which is in turn connected to the other RPi USB port. (Always a good idea to reduce the signal path for the time-critical USB audio).
A proper CD/Bluray reader with a USB-SATA adapter is much better than typical USB DVD readers. The latter are fiddly, the slim drive wears the discs, and can take a long time to figure out how to start ripping.
- Rasbian from http://www.raspberrypi.org/downloads/
The following steps sets up a plain Raspbian to run codplayer with a USB DAC, WIFI network and accessing the disc database over NFS.
This assumes that a standard Raspbian has already been installed and is running.
If the system no longer boots properly after one of the steps, you can always mount the SD card in a Linux box and try to fix the botched files.
Change /etc/network/interfaces:
auto lo
iface lo inet loopback
# auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid ABC
wpa-psk XYZ
Replace ABC and XYZ with the wifi network and password. eth0 is disabled to not waste boot time attempting to get a dhcp lease.
sudo apt-get update
sudo apt-get upgrade
Force performance CPU scaling by adding this line to /etc/rc.local (before any exit 0):
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Install and enable the necessary daemons:
sudo apt-get install nfs-common
sudo update-rc.d rpcbind enable
sudo update-rc.d nfs-common enable
Add the mountpoints to '/etc/fstab` (do not remove any existing lines, and change server names and paths to match your system):
my.nfs.server:/data/music/coddb /mnt/coddb nfs noatime,rw,nodev,nosuid 0 0
To avoid hourly cron jobs messing with playback, change /etc/crontab to make them daily:
# m h dom mon dow user command
17 5 * * * root cd / && run-parts --report /etc/cron.hourly
25 5 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 5 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 5 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
These are no use:
sudo update-rc.d dbus disable
sudo update-rc.d triggerhappy disable
Ensure that the DAC is always ALSA card 0. Create the file /etc/modprobe.d/usb-dac.conf with this line:
options snd slots=snd-usb-audio
And comment out this line in /etc/modprobe.d/alsa-base.conf:
# Keep snd-usb-audio from beeing loaded as first soundcard
# options snd-usb-audio index=-2
Create ~/.asoundrc to set the default card to the USB card:
pcm.0 { type hw; card 0; }
ctl.0 { type hw; card 0; }
pcm.!default pcm.0
ctl.!default ctl.0
If you intend to use the codlcd or codlircd daemons, additional packages are needed:
apt-get install python-smbus lirc
Add this line to /boot/config.txt to activate the lirc kernel module, listening on the GPIO pins used by the control board:
dtoverlay=lirc-rpi,gpio_out_pin=8,gpio_in_pin=4
Use these settings in /etc/lirc/hardware.conf:
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
Install a /etc/lirc/lircd.conf that matches your remote. A config file for Cyrus Commander is available at https://github.com/petli/codplayer/blob/master/etc/lirc/cyrus-commander.conf
Following the steps in INSTALL.md to install all dependencies and install codplayer in a virtualenv with pip.
Install the /etc/udev/rules.d/99-codplayer.rules script to trigger playback when a CD is inserted. This also requires that codctl is found in PATH, easiest with a symlink:
sudo ln -s ~/cod/bin/codctl /usr/local/bin/codctl
Install the /usr/local/bin/trigger_rpi_cdrom_udev.sh script.
Start codplayer by adding these lines to /etc/rc.local (before any exit 0 line):
mkdir -p /var/run/codplayer
chown pi.pi /var/run/codplayer
sudo -u pi /home/pi/cod/bin/codplayerd
sudo -u pi /usr/local/bin/trigger_rpi_cdrom_udev.sh >/var/run/codplayer/trigger.log 2>&1 &
Since codplayer logs a lot and continuously updates state files, these are stored in ramdisk on /var/run to avoid wearing out the SD card with writes. Since it's a ramdisk, the dir must be setup on each boot.
Run ~/cod/bin/codplayerd -d to run codplayer without forking it as a background daemon. See if it logs any errors. This line is OK if the USB DAC isn't connected yet:
c_alsa_sink: error opening card: No such file or directory