I have recorded a .wav file using the command:

arecord test.wav

But when I try to play it, there is no sound output. It's like the raspberry pi is stuck on mute. I initially thought that my microphone was defective, but I sent the wav file to my desktop and played it, and it definitely is not empty.

The audio on my raspberry pi works when I run the hello_audio.bin located in /opt/vc/src/hello_pi/hello_audio And it played a noise through my headphones, so I know it's not my headphones.

  • check the levels in alsamixer – rob Aug 12 '14 at 12:36
up vote 14 down vote accepted

There are a few reasons why this could be happening.

Possible Problem #1: Wrong RasPi hardware audio output selected (auto vs. HDMI vs. headphone/pwm out)

Solution: Force selection of the correct hardware.

amixer cset numid=3 0 # automatic detection (not always reliable) 
amixer cset numid=3 1 # force headphone (PWM) output
amixer cset numid=3 2 # force HDMI output

I like to put these as aliases in my .bashrc file so I don't have to remember the commands:

alias use-audio-auto="amixer cset numid=3 0" # auto
alias use-audio-headphones="amixer cset numid=3 1" # headphones
alias use-audio-hdmi="amixer cset numid=3 2" # hdmi

Possible Problem #2: Misconfigured ALSA subsystem / misconfigured .asoundrc

Solution: Make sure ALSA is configured correctly with good defaults for the RasPi hardware. The /home/pi/.asoundrc file should contain:

pcm.mmap0 {
    type mmap_emul;
    slave {
      pcm "hw:0,0";
    }
}

pcm.!default {
   type hw;
   card 0;
}

ctl.!default {
   type hw;
   card 0;
}

Possible Problem #3: Wrong hardware output device chosen by aplay

Solution: Check what devices are available using aplay -l

Run aplay -l to list playback devices detected, you should see something like this that references bcm2835:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

If you're trying to test the headphone out, you'd force usage of it with:

aplay -Dhw:0,0 test.wav # 'try playing test.wav using hardware card 0, subdevice 0 (headphones)

Then, if you'd like to change the default for your Raspberry Pi, adjust your .asoundrc file to use the right hardware card index #.


Possible Problem 4: Your sound is simply muted/too low and you need to turn it up.

Solution: Make sure alsa-utils is installed and run alsamixer

sudo apt-get install -y alsa-utils
alsamixer

Then use the F1-F6 keys and UI to push up the volume.

alsamixer

Use the arrow keys to jack up the volume and quit.

To save what you changed in alsamixer as defaults, do:

sudo alsactl store 0

Hope that helps! Peace.

  • THANK YOU! I have no idea what installation decided to mute and turn down my RetroPie volume all the way but I had no idea about this alsamixer command! You saved me from reimaging my Raspberry Pi :D – ChrisPrime Feb 24 '15 at 2:00
  • @ChrisPrime no problem ;) – Drew Feb 25 '15 at 5:53
  • 1
    I think the aplay command needs a : in @Drew's answer. I think it should be: ``` aplay -Dhw:0,0 test.wav # 'try playing test.wav using hardware card 0, subdevice 0 (headphones) ``` Actually I'm pretty confident it should be that. Otherwise a great answer! – nomadic_squirrel Oct 3 '16 at 3:33
  • @nomadic_squirrel that is correct :) I've tweaked the answer, thanks! – Drew Jan 10 '17 at 0:59

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.