SSブログ

I2SによるAudio出力 - その5 [Raspberry Pi]

I2S入力を受けるD/Aコンバータを使ってRaspberry Piから古いアクティブスピーカをAirPlay出力に対応させる細工をやってる。前回はRaspbian用のI2Sドライバをインストールして動作確認した。

今回はAirPlay互換サーバであるshairport-syncについて....

4.2  shairport-sync

これでRaspbianからI2Sをドライブする方法はわかった。しかしこれだけでは不便。

僕にとって簡単なのはAirPlayスピーカとして動いてくれること。そうするとforked-daapd(この話はまた別途やるつもり)から直接音が流せる。

AirPlay互換のサーバはいろいろあるらしいが、とりあえずshairport-syncを使ってみることにした。

名前からわかるように、もとはshairportというプロジェクトからforkしたものらしい。本家は3年前で止まっている。shairport-syncも現状ではすごく活発というわけではないようである。

shairport-syncを使うには
  • OpenSSL or mbed TLS (PolarSSL is supported but deprecated)
  • Avahi
  • ALSA and/or PulseAudio
  • libdaemon
  • autoconf
  • automake
  • libtool
  • libpopt
  • libconfig
なんかが必要になるらしい。Raspbianへのインストールを普通にやるには例えばこういうところを参考にしていただきたい。以下は僕がやったこと。

僕のRaspberry PiにはPulseAudioは入っていない。でもALSAでちゃんと動くと書いてあるのでよしとする。Apple Loslessなんか贅沢なものは使わないしそんなデータはないのでlibalacは入れない。

ALSAのために
$ apt install libasound2-dev
だけ追加した。他で足りないのはたまたまなかった(netatalkを入れていたおかげでいろんなのがすでに入っている)のでそのまま
$ git clone https://github.com/mikebrady/shairport-sync.git
$ cd shairport-sync
$ autoreconf -i -f
とすると無事configureが出来上がった。
$ ./configure --help
とするといっぱいスイッチがある。デフォルトが何か書いてないのでとりあえず何かわかっていて必要なものを指定する。
$ ./configure  --without-apple-alac --with-alsa --with-avahi --with-ssl=openssl --with-systemd  --without-pa
しかし、without指定してもチェックで、ライブラリがないと言われる(withoutキーワードは機能しないらしい)。よくわからないので、もう動かないのははずして
$ ./configure --with-alsa --with-avahi --with-ssl=openssl --with-systemd
でやるとMakefileができた。何か足りないとかあるかもしれないけどそのときはやりなおそう。
$ make
$ sudo make install
でできてしまった。

systemctlで起動してみる。
$ sudo systemctl enable shiarport-sync
$ sudo systemctl status shairport-sync
● shairport-sync.service - Shairport Sync - AirPlay Audio Receiver
   Loaded: loaded (/lib/systemd/system/shairport-sync.service; enabled; vendor p
   Active: inactive (dead)
deadとあるのでなんだか死んでるらしい。ちゃんとconfigに記述しないといけないんだろう。
/usr/local/etc/shairport-sync.conf
を編集する。
とりあえず
general =
{
	name = "raspberry speaker";
	output_backend = "alsa";
.
.
}
alsa=
{
	output_device = "hw:1,0";

とだけしてみた。
$ sudo systemctl restart shairport-sync
$ sudo systemctl status shairport-sync
● shairport-sync.service - Shairport Sync - AirPlay Audio Receiver
   Loaded: loaded (/lib/systemd/system/shairport-sync.service; enabled; vendor p
   Active: active (running) since Thu 2017-10-19 16:37:24 JST; 7min ago
 Main PID: 15596 (shairport-sync)
   CGroup: /system.slice/shairport-sync.service
           └─15596 /usr/local/bin/shairport-sync

Oct 19 16:37:24 vega systemd[1]: Started Shairport Sync - AirPlay Audio Receiver
Oct 19 16:37:24 vega shairport-sync[15596]: Successful Startup
で、どうやら動いたらしい(すごい行き当たりばったり。良い子の皆さんは真似しないように)。

僕のMBPの環境設定のサウンドを見ると
1118soundpanel.png
でちゃんと見えている。iTunesからも
1118itunespanel.png
となって出力できるようになっている。

もちろんiPodからも見える。すばらしい。
nice!(0)  コメント(0) 

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。