Raspberry Pi でオーディオサーバを作る

Raspberry Pi model B と Sound Blaster X-Fi Go! Pro が転がっていたので,これらを利用してオーディオサーバを構築します.

今回はShairport-Syncとmpd (Music Player Daemon)を構築します.

インストールと設定

# apt install shairport-sync mpd

Sound Blasterのハードウェア番号を確認します.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Pro [Sound Blaster X-Fi Go! Pro], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Sound Blaster X-Fi Go! Pro が hw:2,0と分かったので,shairport-syncの設定ファイル(/etc/shairport-sync.conf)を編集します

# 抜粋
general = 
{
    interpolation = "soxr";
    output_backend = "alsa";
};

alsa =
{
    output_devce = "hw:2.0";
    mixer_control_name = "PCM";
    mixer_device = "PCM";
};

Shairport-syncを起動します.

# systemctl enable --now shairport-sync

次にmpdの設定ファイル(/etc/mpd.conf)を編集します.ただし,NASのmpd用のディレクトリを/mnt/mpdにマウントしている前提です.

# 抜粋
music_directory    "/mnt/mpd/music"
playlist_directory "/mnt/mpd/playlists"
bind_to_address    "0.0.0.0"
port               "6600"

audio_output {
    type           "alsa"
    name           "Alsa Device"
    device         "hw:2,0"
    mixer_type     "software"
}

mpdを起動します.

# systemctl enable --now mpd