TL;DR
- Linux等ノードがある部屋でspotifyを同時再生します
- 下記を利用します
Spotify Premiumのアカウントで動作確認しています(2025/05/03)
環境はすべてLinuxMint or Ubuntu。まあDebian系環境です。
構成
構成は以下の通り。
^ Spotify Connect
|
|
| <--- client01---USB--- DAC ---ANALOG---speacker
Server[LISITEN] <--- client02---USB--- USB Speacker
<--- client03---PCM--- Speaker
ServerとClientは同居できるのでClientの代表ホスト1台をServer併用でも構いません。
mDNS吐くので同じセグメントにいたほうが楽かもしれません。
設定
Server
適時読み替えてください
### librespot
# cargo突っ込んでない場合:
## https://rustup.rs/
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 依存関係
apt-get install -y build-essential libasound2-dev
cd /opt
git clone https://github.com/librespot-org/librespot
cd librespot
cargo build --release
## building...
./target/release/librespot -j -c /opt/librespot-cache
## OAuth2用のURLをコピー、ブラウザでアカウント認証
## callbackのURL(127.0.0.1)宛はもちろん疎通通らないので、アドレスバーのURLコピーでcurlで叩く。
## curl -L "$your_callbackurl"
ls /opt/librespot-cache
## crendentialが入ってること確認する
### snapcast
## https://github.com/badaix/snapcast/releases/tag/v0.31.0
## https://github.com/badaix/snapweb/releases/tag/v0.8.0
cd /tmp
curl -OL https://github.com/badaix/snapcast/releases/download/v0.31.0/snapserver_0.31.0-1_amd64_bookworm.deb
curl -OL https://github.com/badaix/snapweb/releases/download/v0.8.0/snapweb_0.8.0-1_all.deb
apt-get install -y ./snapserver_0.31.0-1_amd64_bookworm.deb ./snapweb_0.8.0-1_all.deb
rm ./snapserver_0.31.0-1_amd64_bookworm.deb ./snapweb_0.8.0-1_all.deb
$EDITOR /etc/snapserver.conf
# 編集箇所:
# - スレッド数: 必要に応じ変更
# 30 #threads = -1
# - snapweb有効化(適宜uncomment,編集)
# 73 #enabled = true
# 80 #bind_to_address = ::
# 83 #port = 1780
# - ストリームの受け口(適宜uncomment,編集)
# 138 #bind_to_address = ::
# 141 #port = 1704
# - 流し込む口
# - これはいらないのでコメント
# 167 source = pipe:///tmp/snapfifo?name=default
# - librespotを追加
# source = librespot:///opt/librespot/target/release/librespot?enable-oauth&cache=/opt/librespot-cache&name=Spotify
## scrapcastはscrapcast or _scrapcastなユーザ,グループでプロセスが動くので
chown scrapcast:scrapcast -R /opt/librespot-cache
## 起動
systemctl start snapserver
## jounalctl -f して起動問題ないか眺めるなど
1780にアクセスすればsnapweb見える
Spotifyでsnapcast見える
Client
3台とも同じです。
### snapcast
## https://github.com/badaix/snapcast/releases/tag/v0.31.0
cd /tmp
curl -OL https://github.com/badaix/snapcast/releases/download/v0.31.0/snapclient_0.31.0-1_amd64_bookworm.deb
apt-get install -y ./snapclient_0.31.0-1_amd64_bookworm.deb
rm ./snapclient_0.31.0-1_amd64_bookworm.deb
snapclient -l
# 出てくるデバイス眺める
## つなげたいデバイスコピーする
## 例: sysdefault:CARD=Speaker
$EDITOR /etc/default/snapclient
# 下記の容量で追加:
# 7 SNAPCLIENT_OPTS="-h <サーバIP or ホスト名> -s sysdefault:CARD=Speaker"
systemctl restart snapclient
## spotifyをすでに流し込んでいれば音が出る
scrapwebの方で接続端末出るので管理できる。
以上。