Raspberry Pi,Orange PiのALSAによる音声設定は以下コマンドで行います。
https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Simultaneous_playback_problems
alsamixer
以下の画面が表示されるのでF6キーによりデバイスの選択などをして下さい。
MplayerはLircによるコントロールをサポートしています。
http://www.mplayerhq.hu/DOCS/HTML/en/control.html
バックエンドでプレイリストを再生する際はスレーブモードの以下リンクを参照して下さい。
http://www.mplayerhq.hu/DOCS/tech/slave.txt
LIRCによりコントロールする場合は、/etc/lirc/lircrcファイルを作成し内容を以下のようにします。
使用できるコマンド一覧は、 mplayer -input cmdlist
で確認できます。
begin
button = VOLUME_PLUS --->irrecordにより割り当てたリモコンキーを指定します。
prog = mplayer --->キーにより実行されるプログラムを指定します。
config = volume 1 --->mplayer標準のボリュームコマンド:1でボリュームアップ
repeat = 1 --->1で押し続けた場合、繰り返し実行されます。
end
begin
button = VOLUME_MINUS
prog = mplayer
config = volume -1
repeat = 1
end
begin
button = CD_PLAY
prog = mplayer
config = pause
end
begin
button = CD_STOP
prog = mplayer
config = seek 0 1\npause
end
Alsamixerによる左右スピーカ出力テスト
$ speaker-test -c 2
アナログ出力から音が出ない原因
$ sudo alsamixer
mキーの押下によりAudio lineout [Off]をオフに設定します。
上記設定(soundcard 0)を保存します。
$ sudo alsactl store 0
ALSAのリセット方法について
$ sudo alsactl init
ALSA設定(soundcard 0)のリストア
$ sudo alsactl restore 0
man alsactlによりalsactlの機能を確認して下さい。
$ man alsactl
ALSACTL(1) General Commands Manual ALSACTL(1)
NAME
alsactl - advanced controls for ALSA soundcard driver
SYNOPSIS
alsactl [options] [store|restore|init] <card # or id or device>
alsactl monitor <card # or id>
DESCRIPTION
alsactl is used to control advanced settings for the ALSA soundcard drivers. It
supports multiple soundcards. If your card has features that you can't seem to
control from a mixer application, you have come to the right place.
COMMANDS
store saves the current driver state for the selected soundcard to the configu‐
ration file.
restore loads driver state for the selected soundcard from the configuration
file. If restoring fails (eventually partly), the init action is called.
nrestore is like restore, but it notifies also the daemon to do new rescan for
available soundcards.
init tries to initialize all devices to a default state. If device is not known,
error code 99 is returned.
daemon manages to save periodically the sound state.
rdaemon like daemon but restore the sound state at first.
kill notifies the daemon to do the specified operation (quit, rescan,
save_and_quit).
monitor is for monitoring the events received from the given control device.
If no soundcards are specified, setup for all cards will be saved, loaded or
monitored.
ALSAマルチ出力
https://forum.armbian.com/index.php/topic/1960-guide-configuring-orange-pi-pc-for-analog-line-out-jack-audio-output-and-simultaneous-hdmi-output-with-software-mixing/
3.5mmオーデイオジャックのみで音声の同時再生をする場合は、/etc/asound.confは以下のようになります。
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:1,0" # "hw:1,0" means HDMI change to "hw:0,0" for analog lineout jack output
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
<参考>
https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture/Troubleshooting#Simultaneous_playback_problems
ソフトボリュームの追加
https://wiki.archlinuxjp.org/index.php/Advanced_Linux_Sound_Architecture/トラブルシューティング
pcm.!default {
type plug
slave.pcm "softvol"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 4096
buffer_size 131072
rate 50000
}
bindings {
0 0
1 1
}
}
pcm.dsnooper {
type dsnoop
ipc_key 1024
slave {
pcm "hw:0,0"
channels 2
period_time 0
period_size 4096
buffer_size 131072
rate 50000
}
bindings {
0 0
1 1
}
}
pcm.softvol {
type softvol
slave { pcm "dmixer" }
control {
name "Master"
card 0
}
}
ctl.!default {
type hw
card 0
}
ctl.softvol {
type hw
card 0
}
ctl.dmixer {
type hw
card 0
}
Mplayerスレーブモード
http://www.mplayerhq.hu/DOCS/tech/slave.txt
ストリーム音楽をバックエンドで流すためfifoファイルを作成、ストリームデータをパイプ処理します。
mkfifo </tmp/fifofile>
mplayer -slave -input file=</tmp/fifofile> <movie>
ex)
$ mplayer -slave -loop 0 -input file=music/fifofile -playlist music/station100.m3u > /dev/null 2>&1 &
コマンド制御
ターミナルからfifofileにmplayerの各コマンドを受け渡すことが出来ます。
$ echo "pt_step 1" > music/fifofile
$ echo "pause" > music/fifofile
mplayerコマンド一覧
$ mplayer -input cmdlist
Mplayer設定ファイル /etc/mplayer/mplayer.conf
音量とalsa出力優先
##################
# audio settings #
##################
# Use pulse, then alsa, then SDL video with the aalib subdriver by default.
ao=alsa,pulse,sdl:aalib
af=volume=10:1
# Use SDL audio driver with the esd subdriver by default.
#ao = sdl:esd
# Specify the mixer device.
#mixer = /dev/mixer
# Resample the sound to 44100Hz with the lavcresample audio filter.
#af=lavcresample=44100
OrangePiPC ARMBIAN 5.70 stable Debian GNU/Linux 9 (stretch) 4.19.13-sunxi
上記OSのバージョンアップに伴う設定ALSA設定
micの設定はspaceキーで有効になります。
OrangePiPCのマイクはmic1で設定します。boostを大きくしてマイク感度を調整します。
mic1の設定を"MM"(mキーで切替)にしないとハウリング、再生時にノイズが発生します。
再生、録音テストは下記サイトを参照にaplay, arecordコマンドで行います。
https://www.alsa-project.org/main/index.php/SoundcardTesting
録音テスト
$ arecord -vv -d 10 test.wav
再生テスト
$ aplay -vv test.wav
ALSA “dmix plugin supports only playback stream” error when using dmix on beagleboard
pcm.asymed {
type asym
playback.pcm "dmixer"
capture.pcm "hw:0"
}
pcm.dsp0 {
type plug
slave.pcm "asymed"
}
pcm.!default {
type plug
slave.pcm "asymed"
}
pcm.default {
type plug
slave.pcm "asymed"
}