Raspberry Pi のオーディオはどうなっているだろうと思い試してみることにしました。接続にあたり下記のサイトを参考にさせてもらいました。

Raspberry PI Bluetooth Wireless Speaker
http://blog.whatgeek.com.pt/2014/04/raspberry-pi-bluetooth-wireless-speaker/

接続するのはロジテック製の安いワイヤレスホンです。





すでにスマホのBTキーボード化計画でBluetooth 関連のソフトウェアはインストール済みです。参考までコマンドを記載しておきます。


$ sudo apt-get install bluetooth bluez-utils blueman


Bluetooth とオーディオミドルウェアを接続するためのソフトウェアをインストールします。


$ sudo apt-get install bluez-alsa


ワイヤレスホンを認識するか試してみます。


$ hcitool scan
Scanning ...
xx:xx:xx:xx:xx:xx LBT-AR120
$ bluez-simple-agent hci0 xx:xx:xx:xx:xx:xx
Release
New device (/org/bluez/2306/hci0/dev_xx_xx_xx_xx_xx_xx)


ワイヤレスホンのステータスLEDが認識済みに変わりました。無事に認識したみたいです。表示デバイスがないので、前回のBTキーボードと異なり番号合わせの必要はないみたいですね。

ワイヤレスホンを音声出力先として接続します。


$ sudo bluez-test-audio connect xx:xx:xx:xx:xx:xx


ワイヤレスホンから接続を知らせる音とともにLEDの表示が接続に変わりました。成功したようです。

次に起動したときに、すぐ接続するように設定します。


$ bluez-test-device trusted xx:xx:xx:xx:xx:xx
0


うーん、”0”が帰ってきてしまいました。失敗です。参考サイトにならい次のようにしてみました。


$ bluez-test-device connect xx:xx:xx:xx:xx:xx yes
$ bluez-test-device connect xx:xx:xx:xx:xx:xx
1


うまく行ったみたいです。

次は設定ファイルのメンテナンスです(面倒ですねぇ)。まず bluetooth 関連の設定ファイルを編集して、Audio を扱えるようにします。


$ sudo vi /etc/bluetooth/audio.conf


下記のように編集してみました。


# Configurationble=Sink,Source,Socket,Headset,Gateway,Control,Media file for thee
audio service

[General]
# If we want to disable support for specific services
# Defaults to supporting all implemented services
Enable=Sink,Source,Socket,Headset,Gateway,Control,Media

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
SCORouting=PCM

# Automatically connect both A2DP and HFP/HSP profiles for incoming connections.
AutoConnect=true

# Headset interface specific options
[Headset]

# Set to true to support HFP, false means only HSP is supported
HFP=true

# Maximum number of connected HSP/HFP devices per adapter.
MaxConnected=1

# Set to true to enable use of fast connectable mode for HFP
# when incomming call starts
FastConnectable=false

# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
#MPEG12Sources=0


次にホームディレクトリに設定ファイルを作ります。


$ vi ~/.asoundrc


よく分かっていませんが、参考サイトにならい下記のように記述しました。


pcm.bluetooth {
type bluetooth
device xx:xx:xx:xx:xx:xx
}


再生用ソフトウェアをインストールします。


$ sudo apt-get install mpg321


これで再生の準備が整いました。Raspberry Piの中に試せるサウンドはないかなと探してみました。


$ find / -name "*.mp3"
/usr/share/scratch/Media/Sounds/Vocals/Sing-me-a-song.mp3
/usr/share/scratch/Media/Sounds/Vocals/Join-us.mp3
... (snip) ...
/usr/share/scratch/Media/Sounds/Electronic/Peculiar.mp3
/usr/share/pyshared/pygame/examples/data/house_lo.mp3


予想外にも、すごい沢山ありました。(゜ロ゜;) 
ここは "house_lo.mp3" を試してみましょう。出力を"bluetooth"、ゲインを"40"で再生してみます。


$ mpg321 -a bluetooth -g 40 /usr/share/pyshared/pygame/examples/data/house_lo.mp3


おお、ばっちり鳴りました。
設定が面倒ですぐ忘れてしまいそうですが、こうやって記録しておけば役に立つことがあるでしょう。

しかしループサウンドが沢山プリインストールされているのにびっくりしました。DTMソフトが入っていそうですね。そのうち調べてみたいと思います。次は録音にチャレンジしてみようかな。
(^^)/~





Raspberry Pi 2 Model B (1)

  • 出版社/メーカー: Raspberry Pi
  • メディア: エレクトロニクス