![]() ![]() In a future post I will cover playing audio within Python scripts using Pygame. If you want to start playing lists of music then you should explore some of the more advanced media software available for the Pi. This post covers basic audio playing from the command line. The plus (+) and minus (-) keys can be used to adjust the volume of the playback. To play a sound file you simply need to type : omxplayer bubbling_water_1.mp3 ![]() It is installed by default in the latest Raspbian release but if you need to install it manually you can do so using : sudo apt-get -y install omxplayer To get a list of options type : omxplayer You can also use the excellent Omxplayer to play MP3s. In the example below I set the volume to 50% : mpg321 -g 50 bubbling_water_1.mp3 Playing An MP3 Using Omxplayer The volume can be adjusted using the ‘g’ command line option. The MP3 file can be played using : mpg321 bubbling_water_1.mp3 Once installed we can grab an MP3 to experiment with : wget This can be installed using : sudo apt-get -y install mpg321 There are numerous ways to play MP3s from the command line but I tend to use MPG321. If you are lucky the sound will play through your speakers or headphones. Use the following commands to grab some WAV files from my sound archive : wget For previous versions of OpenSprinkler hardware, you can add an external RTC module by connecting the following pins (from RTC module to controller): SDA->SDA, SCL->SCL, VCC->VIN (+5V), GND->GND. Playing A WAV File Using aplayĮverything should be ready to test some sound files. OpenSprinkler hardware 1.4 or above has built-in RTC and backup battery, and the RTC option is turned on by default. But it was this limitation in some commercial offerings that led Zack Lalanne to. Otherwise it defaults to the 3.5mm jack automatically. There is something strangely amusing about the idea of a sprinkler system relying on a cloud. I usually have to do this if I boot the Pi with an HDMI cable plugged in. To force the Raspberry Pi to use the analog output : amixer cset numid=3 1 Where is the required interface : 0=auto, 1=analog, 2=hdmi. You can force it to use a specific interface using : amixer cset numid=3 n Parameters can be specified after the module name.īy default the output is set to automatically select the default audio interface (HDMI if available otherwise analog). # This file contains the names of kernel modules that should be Then add ‘snd-bcm2835’ so it looks like this : # /etc/modules: kernel modules to load at boot time. If the module isn’t loaded automatically when you boot then you can force it to load by using the following process : cd /etc If it isn’t then run the following command : sudo modprobe snd_bcm2835 The first thing to do is run : lsmod | grep snd_bcm2835Īnd check snd_bcm2835 is listed. So I decided to hook up a rechargeable powered speaker I had using a short 3.5mm jack plug lead and see if I could play some WAV and MP3 files. One thing that has changed in the latest Raspian image is that the alsa sound drivers have improved and are enabled by default. I’m making slow progress with my remote controlled car project but I figured I might as well shoe-horn some audio in there as well. So I decided to take another look as I wanted to start adding some audio to my experiments. Things have moved on a bit with the Raspbian image since I wrote my Raspberry Pi Speakers & Analog Sound Test post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |