Raspberry Pi Soundboard

11K98

Intro: Raspberry Pi Soundboard

The purpose of this project is to create a soundboard with a Raspberry Pi, for any sounds. I personally created it for the purpose of Dungeons and Dragons soundboard ambiance. However, you can use this for anything is you customize it

SETUP

For this project you will need:

STEP 1: OS and Installation Time

So, First take your Micro SD card, You need to install some version of Linux. I used Rapbian because it's specifically designed for the Raspberry Pi. Here's the link to get a Raspbian image. Now you need some tool to install it onto the Micro SD card. I used Etcher. It's a cross system tool designed for this. Use this link to download and install it.

Once you've installed Raspbian on the Micro SD card, plug it into the Raspberry Pi's Micro SD card slot, and power it up. It'll say first time setup, so make sure not to power it off while setting up. Once it's up and running, you'll need to make sure you have a few things installed. Python 3, pip3, VLC Media Player, and libvlc. Open up a terminal and run this command.

sudo apt-get install python3 python3-pip vlc libvlc-dev youtube-dl

Now, here's how to verify some of it's installed.

python3

>python3 --version

pip3

>pip3 freeze

VLC and libvlc

>vlc --version

Now, pip3 is a Python 3 Package manager. You can install python libraries with it. There are a few packages you need to install with pip3. Run these commands.

>pip install pafy

>pip install readchar

>pip install python-vlc

>pip install youtube-dl

When you type pip3 freeze, you'll find them there listed there.

STEP 2: Downloading and Running

Now that you've installed everything necessary to run the code, here's where you download the code.

https://github.com/Dude036/soundboard

On the right hand side, you'll see a download button. Download the code, into a folder you want. Open the folder where you downloaded the files in the terminal. Once you're there, read the ReadMe,txt for more information.

To run the Application, you run this command

> python3 main.py

If there are errors at startup. check your last step to make sure it works correctly. Once you've installed and run the program, you're all set! If there are errors while running, be sure to add it as an issue on GitHub and I will make sure it's resolved and fixed

Key Inputs:

  • 0-9: Starts playing the respective sound in the preset you've selected
  • + or -: Pause and Play
  • *: Change preset. By default it'll be the the oldest saved preset. When you press the button, it'll list all of the presets present in the main directory.

STEP 3: Customization and Afterword

Now that you've got the code running, you're welcome to create your own preset. Here's how to do it.

You'll need 10 links, on 10 separate lines of the preset file. Each line shouldn't contain any spaces on either side of the link. YouTube links work as well. Make sure there's an empty line at the end of the file. The program will let you know if it's acceptable or not.

Thanks for checking out this Instructable! If you find any bugs in the code, let me know on the GitHub Project page.

5 Comments

I love this and I noticed you are also a DM. I've been wanting to develop a Pi board to integrate sounds and lights. So one button would play a noise (a dragon roar) and then change some smart lights (red). How would I take your code and do this?
You'd want to start by changing how the playTrack() function works. Right now it only handles audio, but if you add an If statement to check if the input is an audio link or a command, you could issue a output signal to some form of lighting.

As of right now, the program doesn't handle sequences of commands, but you could modify the getPresetTracks() to be have a more advanced type of parsing. I.E multiple commands separated by commas, and put all commands into a 2d array. Once parsed, the playTracks function would have to differentiate between playing an audio track, and updating a lighting array.
I get this error..

ERROR: 7KFoj-SOfHs: YouTube said: Invalid parameters.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 793, in extract_info
ie_result = ie.extract(url)
File "/usr/lib/python3/dist-packages/youtube_dl/extractor/common.py", line 508, in extract
ie_result = self._real_extract(url)
File "/usr/lib/python3/dist-packages/youtube_dl/extractor/youtube.py", line 1688, in _real_extract
expected=True, video_id=video_id)
youtube_dl.utils.ExtractorError: 7KFoj-SOfHs: YouTube said: Invalid parameters.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/pafy/backend_youtube_dl.py", line 40, in _fetch_basic
self._ydl_info = ydl.extract_info(self.videoid, download=False)
File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 816, in extract_info
self.report_error(compat_str(e), e.format_traceback())
File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 621, in report_error
self.trouble(error_message, tb)
File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 591, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: 7KFoj-SOfHs: YouTube said: Invalid parameters.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 141, in <module>
playTrack(getYouTubeAudioTrack(preset[santized]))
File "main.py", line 53, in getYouTubeAudioTrack
video = pafy.new(link)
File "/home/pi/.local/lib/python3.7/site-packages/pafy/pafy.py", line 124, in new
return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts)
File "/home/pi/.local/lib/python3.7/site-packages/pafy/backend_youtube_dl.py", line 31, in __init__
super(YtdlPafy, self).__init__(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/pafy/backend_shared.py", line 97, in __init__
self._fetch_basic()
File "/home/pi/.local/lib/python3.7/site-packages/pafy/backend_youtube_dl.py", line 43, in _fetch_basic
raise IOError(str(e).replace('YouTube said', 'Youtube says'))
OSError: ERROR: 7KFoj-SOfHs: Youtube says: Invalid parameters.

Hi ^^ i get a error code, and i dont know how to fix it:
Traceback (most recent call last):
File"/home/pi/soundboard-master/main.py", line 131, in <module>
keyInput = repr(readchar.readkey())
File "/home/pi/.local/lib/python3.5/site-packages/readchar/readchar.py", line 88, in readkey
c1 = getchar()
File"/home/pi/.local/lib/python3.5/site-packages/readchar/readchar_linux.py", line 12, in readchar
old_settings = termios.tcgetattr(fd)
terminos.error: (25, 'Inappropriate ioctl for device')

do you have an idea what i can do?