Halloween Sound Effects Using Spotify And Raspberry Pi

Scare the neighbours and create a spooky Halloween by using your Raspberry Pi and Spotify.

Halloween Sound Effects Using Spotify And Raspberry Pi - Scare the neighbours and create a spooky Halloween by using your Raspberry Pi and Spotify.
By Marc Littlemore
7 min read

For Halloween back in 2015, I had an unused Raspberry Pi and decided that I should make a Halloween project in order to learn electronics again, and to scare the local children as they came trick or treating. I connected the Raspberry Pi GPIO pins to a breadboard with a big red dome push button. I hid the Pi and electronics inside a shoe box painted black, and made it look like a spooky spider as you can see in the picture below.

Unfortunately, this year I've had a major operation so wasn't feeling up to recreating or bettering my Raspberry Pi project from last year. Instead, I decided to simplify it in order to play random spooky sound effects via the Raspberry Pi and combine it with some spooky ambient music from Spotify. This is a simple project to set up so read on if you want to scare your local trick or treaters!

  • A Raspberry Pi (v2/3 or Zero) and SD card with Raspbian installed
  • A PC or Mac with a Spotify account
  • An audio mixer (or an input into your Mac or PC for software mixing)
  • A set of speakers
  • Some audio cables (probably 3.5mm but it will depend on your setup)

The first thing you'll need to do is to install Node.js on the Rasbperry Pi, assuming that you haven't already. You'll also need git installed for for cloning the project from GitHub, but this should come with the standard Rasbian install.

Next you'll need your PC or Mac up and running and you'll want Spotify on it. You can use a Spotify free account but bear in mind that you'll have adverts popping up which might not scare the neighbours as much as the spooky music will. Alternatively, you can use your own playlist of haunting music or find another one on SoundCloud or YouTube. Again, just watch out for adverts playing or you'll ruin the effect.

You'll need a set of speakers attached to your computer in some way. I run the output of my PC to an amplifier and speakers so I can boost the volume, but you can just use a small pair of computer speakers straight from the computer. Just make sure they're loud enough for people to be able to hear them. I kept my speakers indoors and put them by open windows but if you can run your speakers outside, and they're waterproof, then that'll work too.

Stanton DJ Mixer

Finally, you'll need something to mix the two audio sources together. I've spent nearly 30 years DJing so I had my Stanton DJ mixer to hand and plugged both the PC and the Raspberry Pi into it using RCA cables. This allowed me to alter the volumes of the two input sources and the final volume of the output to my amplifier. If you don't have an audio mixer, you can easily achieve the same thing by using a software mixer on your PC or Mac. Simply attach the output of the Raspberry Pi to the microphone input of your computer using a 3.5mm RCA cable and start the audio mixer in your settings or preferences panel. Note that the output of the Raspberry Pi seems to be really quiet in comparison to the output from the PC. You may be able to change this but I didn't investigate it too much. It just means that you'll need to make the Pi audio a lot higher than that from the PC using your hardware or software mixer.

Install Node.js on your Raspberry Pi

As I love working with Node.js and JavaScript, I decided that this was an easy way to get a project up and running. I installed Node when I first got the Raspberry Pi back in April 2015 so I have version 0.10 by following this guide. However, at the time of writing, I think the easiest way to install v4.2.1 is by following the instructions on the Node Arm GitHub project which does the following:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

You may need to update the gcc compilers too, dependent on what version of Raspbian you're using, but follow the Node Arm guide if you need to do that.

As Linux doesn't have the best out-of-the-box audio support, you'll also have to install the Advanced Linux Sound Architecture (ALSA) library to allow easier playback of MP3 files. One of the NPM packages used is node-speaker and it relies on this library to play audio files. It should be a simple installation using apt-get on the Raspberry Pi as follows:

sudo apt-get install libasound2-dev

Next you'll need to install my Halloween Pi project in order to play the random sounds. As mentioned above, the original project used a button and some LEDs last year so the master branch of the Halloweenpi GitHub project contains that code that uses the GPIOs to send signals from the buttons and to the LEDs. However, I've added a branch which just plays random sound effects in the random-play-sounds branch. Just clone the project from this specific branch and install all of the dependencies:

git clone -b random-play-sounds git@github.com:MarcL/halloweenpi.git
cd halloweenpi
npm install

After installation you should have the project and all of the samples necessary. Run the project and you should start hearing sound effects at intervals of between 15 and 40 seconds. I found this to be about right so that you actually get to hear them without them being too repetitive.

npm start

Raspberry Pi and Spotify

Now you need to also play the spooky ambient music from a Spotify playlist. I created this Spotify Playlist of spooky Halloween noises which you can use. It's nearly 7 hours long so it should be enough for playing throughout the night but feel free to make your own too. You'll have to use your audio mixer to determine the correct balance between the ambient music from Spotify and the one-shot sound effects triggered by the Raspberry Pi. As I mentioned earlier, the Raspberry Pi output seems to be incredibly quiet so I probably had my inputs at around 20% of the PC output mixed with 100% of the Pi output.

All you need to do now is leave this running and position your speakers in a place, and at a volume, where they can be heard by your visitors. A lot of children and their parents commented about how great this sounded so I was pleased with the eventual outcome.

Here's a video of it running in my study, the speakers are hidden behind the curtains with the windows open so it could be heard from the street.

If you want to update the sound effects that are being played then it's really simple. First, you need to add the MP3 files to the /assets directory. Secondly, you need to update the config file which points at them. I chose to be explicit in what sound effects I wanted playing rather than just playing every file it finds in the assets directory. Just update the /config/config.js array of paths to the sound effects and add your new effects, or remove any that you don't want.

module.exports = {
    soundFiles: [
        './assets/cuckoo-clock.mp3',
        './assets/foghorn-doorbell.mp3',
        './assets/ghost-scream.mp3',
        './assets/evil-laugh.mp3',
        './assets/female-scream.mp3',
        './assets/funeral-bells.mp3',
        './assets/howling-wolf.mp3',
        './assets/cat-scream.mp3',
        './assets/woman-shrill-scream.mp3',
        './assets/thriller-laugh.mp3',
        './assets/glados-hello-friend.mp3',
        './assets/glados-hello-where-are-you.mp3',
        './assets/glados-i-see-you.mp3',
        './assets/glados-laugh.mp3',
        './assets/glados-come-over-here.mp3',
        './assets/dalek-exterminate.mp3'
       	]
};

I hope this guide helps you to easily set up your own Halloween Raspberry Pi spooky sound player. If you have any questions then post them below and I'll answer them, or raise and bugs as GitHub issues and I can get them fixed.

Marc Littlemore avatar

I'm Marc Littlemore.

I’m an Engineering Manager at n8n who works with high performing development teams and loves to help to grow other software leaders and engineers.

0
0
0
0

Want to read more?