Despite its small size, the Raspberry Pi is perfectly capable of putting out audio via HDMI, Bluetooth, or analog audio with the 3.5mm onboard headphone jack. If you have just set up your Raspberry Pi and need to perform some testing to get the audio working correctly, or verify that your setup is working, then there are easy ways to test the audio on Raspberry Pi. In this tutorial, you will see how to test audio functionality on a Raspberry Pi.
In this tutorial you will learn:
- How to test audio via
- How to adjust volume level on Raspberry Pi GUI
- How to play audio file via VLC on Raspberry Pi GUI
- How to play MP3 or other audio file from command line
|Category||Requirements, Conventions or Software Version Used|
|Software||speaker-test, VLC, omxplayer|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to test audio on Raspberry Pi
We have various ways to test out the audio on a Raspberry Pi. This includes via the command line and GUI, and by either playing an audio file or generating a speaker test. Check out the different methods below and choose whichever one is most convenient for you.
First thing is first, though. If you are using the GUI on Raspberry Pi, ensure that your volume is loud enough (and that it is not muted). This can be done by clicking on the speaker icon in the upper right corner.
Next, make sure that you have the correct device selected for audio output. This can be done by right clicking on the speaker icon and then selecting which device you want the Raspberry Pi to output audio to. Of course, you will only see one option (the audio jack) if you do not have an extra devices such as a USB speaker or Bluetooth speaker connected to your Raspberry Pi.
With that out of the way, let’s see some ways to test our audio on Raspberry Pi…
- One of the best ways to test out audio, which will work for both command line only systems and GUI, is by using the
speaker-testcommand. The following syntax will do the job:
$ speaker-test -c2 -twav -l3
-coption lets us specify the number of speakers we have, and the
-loption allows us to specify how many tests to perform (each one lasts a second or two). Usually,
-cwill be set to
2, for a left and right speaker. But if you have more speakers, feel free to put a larger number:
$ speaker-test -c4 -twav -l3
A sound will play on each speaker, helping you identify which speakers are working and which ones are not.
- If you would like to play an audio file from command line for testing purposes, then
omxplayeris the perfect tool for the job. The sytnax is very simple and requires no further options:
$ omxplayer audio.mp3
- As for playing audio via GUI, Raspberry Pi OS includes VLC player by default, which is capable of playing almost any kind of audio format. If you do not have VLC already, it can be installed with this command:
$ sudo apt install vlc
There are a variety of other audio players that can be installed on the Raspberry Pi as well – MPV, Audacious, and OSMC to name a few. VLC should be accessible from the system application launcher:
In this tutorial, we saw how to test the audio on a Raspberry Pi system. This included using the
speaker-testcommand, which is a viable method for both command line and GUI systems, and allows users to pinpoint which speaker is not working, in the case of a multi speaker setup. In addition, we learned how to play an audio file from command line with
omxplayerand how to use VLC player via GUI. A big but simple fix also involves adjusting our volume off of mute and selecting the appropriate audio device for output.