16

I am running RPi headless and would like it to play a sound (like when a Mac boots) so I know it is booting and how far it got. I can play music/wav files now, What is the best way to have something play a sound file when RPi boots?

Note, it doesn't have to be very early on, it would be fine if RPi boots, does everything it needs to do and then when it is ready for someone to login the sound plays.

Update 1: I am using Raspbian “wheezy”

2
  • You'll need to create your own init script. But the process of doing this depends on what distro you are using. Which is it?
    – Jivings
    Commented Nov 18, 2012 at 19:06
  • FYI, I didn't get notified of that update because it's not a comment reply.
    – Jivings
    Commented Nov 18, 2012 at 23:15

2 Answers 2

12

Essentially all you have to do to create a start-up script is the following:

Create a file here and make it executable:

sudo nano /etc/init.d/start-sound && chmod +x $_

Add it to the default runlevel:

sudo update-rc.d start-sound defaults

All your script really needs to do is call aplay on an audio file. Something like this:

# /etc/init.d/start-sound

echo "Playing startup sound"
aplay /path/to/file.mp3 2>&1 >/dev/null &
4
  • Maybe this should be a new question, but after installing alsa-util on Raspbmc, I get ALSA lib confmisc.c:768:(parse_card) cannot find card '0' when I run aplay /home/pi/beep-3.mp3 where beep-3.mp3 is an mp3 file of a beep sound. Commented Nov 19, 2012 at 1:56
  • 2
    @HeatfanJohn Try sudo modprobe snd_bcm2835. If that doesn't work then ask a new question :)
    – Jivings
    Commented Nov 19, 2012 at 8:29
  • That fixed my problem. Thanks for your help! Looks like this question was my problem. Thanks again. Commented Nov 19, 2012 at 15:02
  • while doing sudo nano /etc/init.d/start-sound && chmod +x $_ I am getting error as chmod: changing permission of 'start-sound': Operation not permitted. My raspbian os version is jessie.
    – Dipak
    Commented Jan 10, 2016 at 12:51
0

Add the command to play the sound at the end of /etc/rc.local

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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