Warning: Undefined variable $post_id in /bitnami/wordpress/wp-content/themes/stardust/single.php on line 9
class="post-28 post type-post status-publish format-standard hentry category-raspberry-pi" id="post-28">

Aug 21 2016

Sound Driver

Category: Raspberry Pidq @ 5:08 PM

http://plugable.com/2014/11/06/how-to-switch-to-usb-audio-on-raspberry-pi/

http://www.instructables.com/id/Use-USB-Sound-Card-in-Raspberry-Pi/?ALLSTEPS

In the Debian “Squeeze” image the ALSA sound drivers are considered experimental and have been disabled by default. To enable sound you need to type the commands below into the command line :

sudo apt-get install alsa-utils


That will install the required sound driver files and tools. Type “Y” when prompted. The following command will load the sound driver :

sudo modprobe snd_bcm2835


By default the output is set to automatically select the interface (HDMI if available otherwise analog). You can force it to use a specific interface using :

sudo amixer cset numid=3 <n>


Where <n> is the required interface : 0=auto, 1=analog, 2=hdmi. To force the Raspberry Pi to use the analog output :

sudo amixer cset numid=3 1


You will need to run the modprobe command again when your Pi is rebooted/restarted.


Playing A WAV File

In order to play a WAV file we need a file to play. Type the following command to download a test WAV file :

sudo wget http://www.freespecialeffects.co.uk/soundfx/sirens/police_s.wav

sudo wget http://www.freespecialeffects.co.uk/soundfx/sirens/police_s.wav
sudo wget http://www.freespecialeffects.co.uk/soundfx/computers/bleep_01.wav


Now we can play it :

sudo aplay police_s.wav


If you are lucky the sound will play through your speakers or headphones.

I tried a number of WAV files but only some of them played. Hopefully this will be resolved in future releases of the sound drivers.


Playing an MP3 Using MPG321

There are numerous ways to play MP3s from the command line but I tend to use MPG321. This can be installed using :

sudo apt-get -y install mpg321


Once installed we can grab an MP3 to experiment with :

wget http://www.freespecialeffects.co.uk/soundfx/household/bubbling_water_1.mp3


The MP3 file can be played using :

mpg321 bubbling_water_1.mp3


The volume can be adjusted using the ‘g’ command line option. In the example below I set the volume to 50% :

mpg321 -g 50 bubbling_water_1.mp3






USB Sound: https://www.pubnub.com/blog/2015-10-14-text-to-speech-audio-broadcast-with-raspberry-pi/

Comments are closed.