LoginSignup
2
0

More than 5 years have passed since last update.

Shairport-sync+ Shaircast で部屋中のRaspiにiPhoneの音楽を送りつけちゃおう

Posted at

背景

家中に有るRaspiのShairport-syncを一斉に鳴らしたくなったので検討しました。

はじめに

Raspi3の上でShariport-syncとShaircastを入れて鳴らすとプツプツ途切れてしまうので、現実的にむつかしいかもです。
Macとかで動かすかな。。。

手順

Raspbianセットアップ(基本割愛)

OSインストール後にMac/Winから/boot直下にsshというファイルを置いて初回起動時にsshをEnableにする。

以下で、3.5mmジャックを多少マシにする。

/boot/config.txt
##以下を追加
audio_pwm_mode=2

shairport-sync

https://qiita.com/yuyakato/items/600f499cf0610bfc1a16
と基本的には同じですが、ユーザーのホームディレクトリへのアクセス権が必要なので以下がお勧めです。

# 必要なライブラリをインストールする
sudo apt-get update
sudo apt-get -y install libshairport2 autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev 
# pulseaudioを使う人はlibpulse-devを入れたほうが良いですがオススメしません

cd ~
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-soxr --with-systemd
#--with-paでPulseAudio対応になりますが、pulse経由だと音飛びがでるので見送りました。

make
sudo groupadd -r shairport-sync
sudo useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync
sudo mkdir /home/shairport-sync
sudo chown shairport-sync:shairport-sync /home/shairport-sync
sudo make install
sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync

sudo vi /usr/local/etc/shairport-sync.conf # お好みに合わせて名前などを弄りましょう。

その他:
aplay: pcm_write:2011: 書込エラー: システムコール割り込み
とかいうエラーが出た時がありました。sudo rpi-updateでなおりました。

Shaircastインストール

まずはnode関連の最新化
https://qiita.com/mascii/items/77c685df65c4cbca9315
をベースに以下実施。

sudo apt-get install -y nodejs npm
sudo npm cache clean
sudo npm install npm n -g
sudo n lts

mdnsでエラーが出るので以下をインストール

sudo apt-get -y install libavahi-compat-libdnssd-dev

shaircastのインストールについては、本家(https://github.com/nguyer/shaircast )よりも以下の方が機能が良さそうですのでそっちを使います。
なので、設定ファイルの書き方は
https://github.com/dfrommi/shaircast/tree/remote-control-and-more
を参考にして下さい。

cd ~
git clone -b remote-control-and-more https://github.com/dfrommi/shaircast.git
cd shaircast

ここで、package.jsonを弄ります。デフォルトの内容ではairtunesのインストールで失敗するのです。

package.json
    "airtunes": "git://github.com/marcokeur/node_airtunes.git#master",
    "nodetunes": "git://github.com/gpjt/nodetunes.git#master",
    "speaker": "^0.3.0"

のように書き換え。https://github.com/nguyer/shaircast/pull/8/files を参照。

npm install
#warningなどが山のように出ますが、動きます。

気付きなど

単体とAllで行くときの音量レベルが違う

気がする。

configファイル

config.json中でxxx.local的なホスト名を使うと音が出ない。IPで入れるべし。
実行時にavahiからエラーが出てるのでその影響と思われるが、詳しく調べてない。

以上

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0