Advertisement
Tritonio

No sound over HDMI raspberry

Mar 15th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. I had the same problem: no sound over HDMI after connecting Raspberry Pi to my 21" HDTV (although my PlayStation 3 and Xbox 360 worked just fine). As stated above, I too had to edit the config.txt file and add the following line:
  2.  
  3. hdmi_drive=2
  4.  
  5. Config.txt is located in /boot and I edited it by loading up LXTerminal and using the following command line:
  6.  
  7. $ sudo nano /boot/config.txt
  8.  
  9. After adding the "hdmi_drive=2" line at the bottom, I typed ctrl-o to write the changes and ctrl-x to exit the nano text editor. I rebooted and the HDMI sound finally worked!
  10.  
  11. This is caused by some computer monitors which select DVI mode even if an HDMI cable is connected. This fix may be necessary even if other HDMI devices work perfectly on the same monitor (or TV)!
  12.  
  13. Edit the configuration file - see the instructions at R-Pi_ConfigurationFile.
  14.  
  15. Add the following line to the configuration file /boot/config.txt:
  16.  
  17. hdmi_drive=2
  18.  
  19. This will force it to select HDMI mode.
  20.  
  21. You might need as well:
  22.  
  23. hdmi_force_hotplug=1
  24. hdmi_force_edid_audio=1
  25.  
  26. More reasons why sound does not work with an HDMI monitor
  27.  
  28. With an HDMI connection it might be possible to hear:
  29.  
  30. /opt/vc/src/hello_pi/hello_audio/hello_audio.bin 1
  31.  
  32. but not:
  33.  
  34. aplay /usr/share/sounds/alsa/Front_Center.wav
  35.  
  36. Firstly, it seems that some HD TVs mute audible sound output when there is no digital input, and slowly fade the sound up and down at the start and end of digital input. This means that short duration sounds will not be heard. A work around is to play longer duration wav files.
  37.  
  38. Secondly, it seems that some HD TVs mute audible sound output when there is only one channel of digital input. So, as the file Front_Center.wav is mono, it might not be heard. ALSA aplay uses the file information header to configure its digital output. And the aplay -c 2 option does not over-ride the settings aplay picks up from the file information header. So, if your HD TV doesn't accept just one channel of digital input, you cannot use aplay to hear a mono wav file. However, with the command speaker-test, the -c2 option does work, and sets 2 channels in the digital stream. So speaker-test can be used to hear the file Front_Center.wav in either the left or right speaker using the -s option 1 or 2. For example
  39.  
  40. speaker-test -c 2 -s 1 -t wav -W /usr/share/sounds/alsa -w Front_Center.wav
  41.  
  42. should be heard on the left speaker. But note that the command speaker-test seems only to like mono wav files, and seems not to play stereo wav files.
  43.  
  44. The command aplay plays 2 channel stereo wav files in stereo sound without problem (provided they last longer than the time it takes the TV to unmute and remute). A helpful example I found is the stereo file LRMonoPhase4.wav at the Kozco web site [4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement