Spotifyを家中で聞きたい・・家中を音楽で満たしたい・・・そう思ったことはありませんか?私はあります。
でもケーブルを家中に敷設するのは見た目も悪いし・・・そう思ったことはありませんか?私はあります。
てことでRaspberry Piを利用してMultiRoom Audioをしてみました。
全体的なイメージはこんな感じです。
順を追って行きます。
サーバー編
Snapcast Serverのインストール
バージョンなどはReleasesのページで適宜最新にして読み替えてください。
wget https://github.com/badaix/snapcast/releases/download/v0.21.0/snapserver_0.21.0-1_armhf.deb sudo dpkg -i snapserver_0.21.0-1_armhf.deb
Raspotifyの設定
/etc/default/raspotify を編集します。
sudo nano /etc/default/raspotify
# /etc/default/raspotify -- Arguments/configuration for librespot # Device name on Spotify Connect DEVICE_NAME="<好きな名前(日本語可)>" # Bitrate, one of 96 (low quality), 160 (default quality), or 320 (high quality) BITRATE="320" # Additional command line arguments for librespot can be set below. # See `librespot -h` for more info. Make sure whatever arguments you specify # aren't already covered by other variables in this file. (See the daemon's # config at `/lib/systemd/system/raspotify.service` for more technical details.) # # To make your device visible on Spotify Connect across the Internet add your # username and password which can be set via "Set device password", on your # account settings, use `--username` and `--password`. # # To choose a different output device (ie a USB audio dongle or HDMI audio out), # use `--device` with something like `--device hw:0,1`. Your mileage may vary. # OPTIONS="--username <SPOTIFYのユーザーネーム> --password <SPOTIFYのパスワード> --zeroconf-port 65444" # Uncomment to use a cache for downloaded audio files. Cache is disabled by # default. It's best to leave this as-is if you want to use it, since # permissions are properly set on the directory `/var/cache/raspotify'. #CACHE_ARGS="--cache /var/cache/raspotify" # By default, the volume normalization is enabled, add alternative volume # arguments here if you'd like, but these should be fine. #VOLUME_ARGS="--enable-volume-normalisation --linear-volume --initial-volume=100" # Backend could be set to pipe here, but it's for very advanced use cases of # librespot, so you shouldn't need to change this under normal circumstances. BACKEND_ARGS="--backend pipe --device /tmp/snapfifo"
必要なのはDEVICE NAME、OPTIONS、BACKEND_ARGSの3つ
OPTIONSには開放するポート番号を--zeroconf-port以降に、
BACKEND_ARGSにはパイプを指定してあげましょう。
Snapcast Serverの設定
/etc/default/snapserver を編集しますが、今回は特に必要ありません。
sudo nano /etc/default/snapserver
次にサンプルレートを変更しましょう
サンプルレートは`/etc/snapserver.conf`で変更できます。
[stream]セクションに置くみたいです。
source = pipe:///tmp/snapfifo?name=default sampleformat = 44100:16:2
それぞれ設定した後は再読込しておきましょう。
sudo service snapserver restart sudo service raspotify restart
クライアント側のラズパイの設定
snapclientのインストール
wget https://github.com/badaix/snapcast/releases/download/v0.21.0/snapclient_0.21.0-1_armhf.deb sudo dpkg -i snapclient_0.21.0-1_armhf.deb
Snapcast Clientの設定
/etc/default/snapclientの設定
sudo nano /etc/default/snapclient
START_SNAPCLIENT=true SNAPCLIENT_OPTS="--host"
hostにはサーバーのIPアドレスを指定してください。
Snapclientのリスタート
sudo service snapclient restart