Musik im Raum

Für die Musik läuft ein MPD auf einem Raspberry PI 3

Hostname rpi3.raum.ctdo.de User: pi Pass: wasserfall

Per ssh einloggen und „ncmpc“ eingeben.

Musik per Webbrowser steuern: http://raum.ctdo.de/mpd/

Die Quellenwahl und Lautstärke kann durch das Projekt Audiosteuerung gemacht werden.

Konfiguration auf dem Raspberry Pi

/etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.

# Activate iptables firewall: Only access from CTDO-IP-Range
iptables -F INPUT
iptables -P INPUT DROP
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -i lo -m conntrack --ctstate NEW -j ACCEPT
iptables -A INPUT -s 195.160.168.0/23 -m conntrack --ctstate NEW -j ACCEPT
iptables -A INPUT -j REJECT

# Activate ip6tables firewall: Only access from CTDO-IP-Range (IPv6)
ip6tables -F INPUT
ip6tables -P INPUT DROP
ip6tables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
ip6tables -A INPUT -p icmpv6 -j ACCEPT
ip6tables -A INPUT -i lo -m conntrack --ctstate NEW -j ACCEPT
ip6tables -A INPUT -s fe80::/10,2001:67c:275c::/48 -m conntrack --ctstate NEW -j ACCEPT
ip6tables -A INPUT -j REJECT

# Make sure that volume is UP when rpi has booted
amixer set Master 100%

# Do NOT play anything after reboot. (Don't freak out the one who just gave power to the room)
mpc pause

# Bridge script to give information about current file to MQTT.
/usr/bin/python3.2 /home/lucas/mpd-to-mqtt.py  >> /dev/null &

exit 0

/etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#iface eth0 inet manual

#allow-hotplug wlan0
#iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#allow-hotplug wlan1
#iface wlan1 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto eth0
iface eth0 inet static
        address 195.160.169.17
        netmask 255.255.255.128
        gateway 195.160.169.1
	dns-domain raum.chaostreff-dortmund.de
	dns-nameserver 91.204.6.66
	dns-nameserver 91.204.4.5

iface eth0 inet6 static
        address 2001:67c:275c:a9::11
        netmask 64

/etc/mpd.conf

music_directory		"/srv/filebase/audio"
playlist_directory		"/srv/filebase/audio"
db_file			"/srv/filebase/raspberry_netfs/raum3/mpd/tag_cache"
log_file			"/var/log/mpd/mpd.log"
pid_file			"/var/run/mpd/pid"
state_file			"/var/lib/mpd/state"
sticker_file                   "/srv/filebase/raspberry_netfs/raum3/mpd/sticker.sql"
user				"mpd"
bind_to_address         "127.0.0.1"
bind_to_address         "195.160.169.17"
bind_to_address         "::1"
bind_to_address         "2001:67c:275c:a9::11"
zeroconf_enabled		"yes"
zeroconf_name			"Music Player"
input {
        plugin "curl"
}
audio_output {
	type		"alsa"
	name		"My ALSA Device"
	format		"48000:16:2"	# optional
	#mixer_control	"Master"	# optional
	mixer_control	"none"	# optional
}
filesystem_charset		"UTF-8"
id3v1_encoding			"UTF-8"

/etc/modprobe.d/alsa-base.conf

music_directory		"/srv/filebase/audio"
playlist_directory		"/srv/filebase/audio"
db_file			"/srv/filebase/raspberry_netfs/raum3/mpd/tag_cache"
log_file			"/var/log/mpd/mpd.log"
pid_file			"/var/run/mpd/pid"
state_file			"/var/lib/mpd/state"
sticker_file                   "/srv/filebase/raspberry_netfs/raum3/mpd/sticker.sql"
user				"mpd"
bind_to_address         "127.0.0.1"
bind_to_address         "195.160.169.17"
bind_to_address         "::1"
bind_to_address         "2001:67c:275c:a9::11"
zeroconf_enabled		"yes"
zeroconf_name			"Music Player"
input {
        plugin "curl"
}
audio_output {
	type		"alsa"
	name		"My ALSA Device"
	format		"48000:16:2"	# optional
	#mixer_control	"Master"	# optional
	mixer_control	"none"	# optional
}
filesystem_charset		"UTF-8"
id3v1_encoding			"UTF-8"

/etc/fstab

Die ersten drei Einträge sollten bereits vorhanden sein, es wird nur der zusätzliche Link auf die Filebase benötigt. Mit

mkdir -p /srv/filebase

vorher das Verzeichnis auch erstellen.

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p6  /boot           vfat    defaults          0       2
/dev/mmcblk0p7  /               ext4    defaults,noatime  0       1
# filebase.raum.chaostreff-dortmund.de/pub
//195.160.169.11/pub /srv/filebase cifs auto,noperm,username=anonymous,password=bla 0 0

/etc/asound.conf

pcm.dmixer {
    type dmix
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0666 # mixing for all users
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 44100
    }
    bindings {
        0 0
        1 1
    }
}

pcm.dsp0 {
    type plug
    slave.pcm "dmixer"
}

pcm.!default {
    type plug
    slave.pcm "dmixer"
}

pcm.default {
   type plug
   slave.pcm "dmixer"
}

ctl.mixer0 {
    type hw
    card 0
}