音が出ない……。いや出た!
追記
情報源
- http://www.yam-web.net/raspberry-pi/music.html
- https://www.raspberrypi.org/forums/viewtopic.php?t=248094
- https://github.com/raspberrypi/firmware/issues/1243
HDMIで音が出ないという問題が寄せられている。前にコメントいただいたときもHDMIから音が出ないと聞いた。
でも私の環境では頑張ったら音が出た。手順をメモする。
前提
- 音量
- Raspbian Desktop 音量 50%以上(Mute OFF)
- Display 音量 50%以上
- 接続
- Raspberry Pi 4B HDMI 0(not HDM 1)
- Display HDMI 1(not HDM 2)
- HDMI ケーブル+変換コネクタ
バージョン等
$ cat /proc/cpuinfo ... Hardware : BCM2835 Revision : c03112 Serial : ******************** Model : Raspberry Pi 4 Model B Rev 1.2
$ uname -a Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
$ vcgencmd version Sep 24 2019 17:34:30 Copyright (c) 2012 Broadcom version cd3add54955f8fa065b414d8fc07c525e7ddffc8 (clean) (release) (start)
$ cat /etc/rpi-issue Raspberry Pi reference 2019-09-26 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 80d486687ea77d31fc3fc13cf3a2f8b464e129be, stage4
$ xrandr --listmonitors Monitors: 2 0: +*HDMI-1 1920/160x1080/90+0+0 HDMI-1 1: +HDMI-2 1024/160x768/90+0+0 HDMI-2
$ tvservice -l 2 attached device(s), display ID's are : Display Number 2, type HDMI 0 Display Number 7, type HDMI 1
~/.asoundrc
ファイルはなかった。
cd ~ ls -a | grep .asoundrc
手順
1. /boot/config.txt
修正
sudo vi /boot/config.txt
以下を追記する。
hdmi_drive=2
例えば以下のように。
[pi4] #hdmi_safe=1 hdmi_force_hotplug=1 hdmi_ignore_edid=0xa5000080 disable_overscan=1 hdmi_drive=2 ...
/boot/config.txt
# For more options and information see # http://rpf.io/configtxt # Some settings may impact device functionality. See link above for details # uncomment if you get no picture on HDMI for a default "safe" mode #hdmi_safe=1 # uncomment this if your display has a black border of unused pixels visible # and your display can output without overscan #disable_overscan=1 # uncomment the following to adjust overscan. Use positive numbers if console # goes off screen, and negative if there is too much border #overscan_left=16 #overscan_right=16 #overscan_top=16 #overscan_bottom=16 # uncomment to force a console size. By default it will be display's size minus # overscan. #framebuffer_width=1280 #framebuffer_height=720 # uncomment if hdmi display is not detected and composite is being output #hdmi_force_hotplug=1 # uncomment to force a specific HDMI mode (this will force VGA) #hdmi_group=1 #hdmi_mode=1 # uncomment to force a HDMI mode rather than DVI. This can make audio work in # DMT (computer monitor) modes #hdmi_drive=2 # uncomment to increase signal to HDMI, if you have interference, blanking, or # no display #config_hdmi_boost=4 # uncomment for composite PAL #sdtv_mode=2 #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 # Uncomment some or all of these to enable the optional hardware interfaces #dtparam=i2c_arm=on #dtparam=i2s=on #dtparam=spi=on # Uncomment this to enable infrared communication. #dtoverlay=gpio-ir,gpio_pin=17 #dtoverlay=gpio-ir-tx,gpio_pin=18 # Additional overlays and parameters are documented /boot/overlays/README # Enable audio (loads snd_bcm2835) dtparam=audio=on # 2019-11-29 program_usb_boot_mode=1 program_usb_boot_timeout=1 [pi3] # 2018-09-22 cocopar 13.3inch 16:9 Display max_usb_current=1 hdmi_group=2 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0 gpu_mem=256 # 2018-09-21 Elecrow Display start # 古いディスプレイ(1024x768まで対応)だとブートしなくなる。(ディスプレイが暗い状態でチカチカするのを無限ループする)その場合はコメントアウトする。 #max_usb_current=1 #hdmi_group=2 #hdmi_mode=1 #hdmi_mode=82 #hdmi_cvt 1920 1080 60 6 0 0 0 #hdmi_drive=2 [pi3+] # 2018-09-22 cocopar 13.3inch 16:9 Display max_usb_current=1 hdmi_group=2 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0 gpu_mem=256 # 2018-09-21 Elecrow Display start # 古いディスプレイ(1024x768まで対応)だとブートしなくなる。(ディスプレイが暗い状態でチカチカするのを無限ループする)その場合はコメントアウトする。 #max_usb_current=1 #hdmi_group=2 #hdmi_mode=1 #hdmi_mode=82 #hdmi_cvt 1920 1080 60 6 0 0 0 #hdmi_drive=2 [pi4] #hdmi_safe=1 hdmi_force_hotplug=1 hdmi_ignore_edid=0xa5000080 disable_overscan=1 hdmi_drive=2 # Enable DRM VC4 V3D driver on top of the dispmanx display stack dtoverlay=vc4-fkms-v3d max_framebuffers=2 # 2019-11-29 [HDMI:0] # 2018-09-22 cocopar 13.3inch 16:9 Display max_usb_current=1 hdmi_group=2 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0 gpu_mem=256 program_usb_boot_mode=1 program_usb_boot_timeout=1 # 2019-11-29 [HDMI:1] # 2018-09-21 Elecrow Display start # 古いディスプレイ(1024x768まで対応)だとブートしなくなる。(ディスプレイが暗い状態でチカチカするのを無限ループする)その場合はコメントアウトする。 max_usb_current=1 hdmi_group=2 hdmi_mode=1 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0 hdmi_drive=2 program_usb_boot_mode=1 program_usb_boot_timeout=1 [all] #dtoverlay=vc4-fkms-v3d
2. /boot/cmdline.txt
/boot/cmdline.txt
に以下を追記。(改行せず)
snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_compat_alsa=1
参考URLには...alsa=0
とあるが、読み進めていくと問題ありとして...alsa=1
になっている。なので上記でよい。
私の環境では以下。
sudo vi /boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=ec335738-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_compat_alsa=1
再起動する。
reboot
3. amixer
出力先の設定
3-1. サウンドデバイス情報を調べる
$ aplay -l **** ハードウェアデバイス PLAYBACK のリスト **** カード 0: ALSA [bcm2835 ALSA], デバイス 0: bcm2835 ALSA [bcm2835 ALSA] サブデバイス: 4/4 サブデバイス #0: subdevice #0 サブデバイス #1: subdevice #1 サブデバイス #2: subdevice #2 サブデバイス #3: subdevice #3 カード 0: ALSA [bcm2835 ALSA], デバイス 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 0: ALSA [bcm2835 ALSA], デバイス 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 1: HDMI [bcm2835 HDMI], デバイス 0: bcm2835 HDMI [bcm2835 HDMI] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 2: b1 [bcm2835 HDMI 1], デバイス 0: bcm2835 HDMI 1 [bcm2835 HDMI 1] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 3: Headphones [bcm2835 Headphones], デバイス 0: bcm2835 Headphones [bcm2835 Headphones] サブデバイス: 1/1 サブデバイス #0: subdevice #0
もし/boot/cmdline.txt
をやらなければ、サウンドデバイスが正しく取得できない。以下のようにデバイス名がすべて0
になってしまう。
$ aplay -l **** ハードウェアデバイス PLAYBACK のリスト **** カード 0: ALSA [bcm2835 ALSA], デバイス 0: bcm2835 ALSA [bcm2835 ALSA] サブデバイス: 7/7 サブデバイス #0: subdevice #0 サブデバイス #1: subdevice #1 サブデバイス #2: subdevice #2 サブデバイス #3: subdevice #3 サブデバイス #4: subdevice #4 サブデバイス #5: subdevice #5 サブデバイス #6: subdevice #6 カード 0: ALSA [bcm2835 ALSA], デバイス 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI] サブデバイス: 1/1 サブデバイス #0: subdevice #0 カード 0: ALSA [bcm2835 ALSA], デバイス 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1] サブデバイス: 1/1 サブデバイス #0: subdevice #0
もし正しく取得できたなら、HDMI
, b1
, Headphones
などのサウンドカード名? が見えるはず。上記のように0
となるなら/boot/cmdline.txt
の手順に従うこと。
以下でHDMIディスプレイのイヤホンジャックから再生
aplay -D hw:CARD=HDMI,DEV=0 /usr/share/sounds/alsa/Rear_Center.wav
以下で本体イヤホンジャックから再生。
aplay -D hw:CARD=Headphones,DEV=0 /usr/share/sounds/alsa/Rear_Center.wav
3-2. デフォルト出力先サウンドデバイスを設定する
デフォルトの出力先を設定する。
番号 | 意味 | コマンド |
---|---|---|
0 |
自動 | amixer -q cset numid=3 0 |
1 |
アナログ(本体イヤホンジャック) | amixer -q cset numid=3 1 |
2 |
HDMI 0(ディスプレイのイヤホンジャック) | amixer -q cset numid=3 2 |
3 |
HDMI 1(ディスプレイのイヤホンジャック) | amixer -q cset numid=3 3 |
現在の出力先を確認するなら以下。
amixer cget numid=3
私は以下のように設定した。
amixer -q cset numid=3 2
これで以下のように出力先デバイスをHDMIに指定せずとも、デフォルトでHDMIのイヤホンジャックから音が再生された!
aplay /usr/share/sounds/alsa/Rear_Center.wav
大成功!
3-3. 音声出力を確認する
前回まで
ハード。
- Raspberry Pi 4B (4GB) を2個予約した(KSY先行予約販売)
- Raspberry Pi 4B 届いた! 開封の儀
- Raspberry Pi 4B ヒートシンク取付
- Raspberry Pi 4B ケース装着
- HDMIまちがえて買ってた……(type A, C, D の罠)
ソフト。
- RPI4B Raspbian Buster USB boot 未対応……
- Raspbian Buster 2019-09-26 インストール
- Raspbian Buster 2019-09-26 ダウンロード
- Raspbian Buster 2019-09-26 HDMI設定について調べた
- Raspbian Buster 2019-09-26 インストール前の設定(Wi-Fi)
設定。
- Raspbian Buster ヘッドレス 初期設定 できないか調べた
- Raspberry Pi 4B でSSHログインできた
- Raspberry Pi 4B 初期設定(ヘッドレス)
- Raspberry Pi 4B SDブート+USBルート(≒USB boot)に成功
- VNCからRaspbian Busterへログインする方法を調べる
- VNCからRPI4B Raspbian Busterを初期セットアップする
- VNCからRPI4B Raspbian Busterをセットアップする
- Raspberry Pi 4B に HDMIケーブル A-D + 変換キャップ type A-C でディスプレイ表示する
- Raspberry Pi 4Bのハードウェア情報を表示する(cat /proc/cpuinfo)
- Raspberry Pi 4B 音を出す(本体イヤホンジャック)
データ移行。
セキュリティ。
企業。