Raspberry PiでBluetoothスピーカーを鳴らす
This text is also text!
Preparation
Amazon.co.jpで買ったEWA A106というスピーカーです
PulseAudioとPulseAudioのBluetoothスピーカーのモジュールをインストールします。
1 | sudo apt-get install pulseaudio pulseaudio-module-bluetooth |
Setting
PulseAudioの設定
PulseAudioを設定するため、/etc/pulse/default.paを編集します
1 | sudo nano /etc/pulse/default.pa |
ファイルの最後に次の行を追加します。
1 | # automatically switch to newly-connected devices |
bluetooth権限追加
sudoなしでBluetoothが制御できるため、ユーザーをbluetoothグループに入れル必要があります。
1 | sudo usermod -G bluetooth -a $USER |
## 動作
Bluetoothスピーカーをペアリングするためpulseaudioを起動します
1 | pulseaudio --start |
bluetoothctlコマンドを起動して以下操作します。
1 | $ bluetoothctl |
ペアリング
pairコマンドでペアリングします
1 | [bluetooth]# pair 3D:8F:2B:2E:E4:07 |
Pairing successfulと出れば成功です。
ついでにtrustコマンドでTrustリストに登録します
1 | [bluetooth]# trust 3D:8F:2B:2E:E4:07 |
connectコマンドでスピーカーに接続します。
1 | [bluetooth]# connect 3D:8F:2B:2E:E4:07 |
終了
以下のコマンドを実行してペアリングを終了します。
1 | [EWA Audio A106] |
テスト
ファイルを再生して音を鳴らして確認しましょう。
1 | $ aplay /usr/share/sounds/alsa/Front_Center.wav |
音量調整
alsamixer コマンドで調整できます。
上下キーで音量を調整でき、F6 キーで出力先(ヘッドホンジャック、HDMI など)を変更できます。
また、M ボタンを押すとミュート/ミュート解除の切り替えができます