How to make a SoundBoard using Raspberry Pi | STEP BY STEP GUIDE |MEMEBOX

Today I am going to show you how to make a Soundboard using Raspberry Pi. A soundboard is a box with a lots of button in it like a Synth box, upon pressing each button it plays a sound or tone or musical note. This can be used for teaching kids different animal sounds, for party purpose or to create a meme box for fun purpose.

Below are my affiliate links to the product used for this project

Key Pad

Banggood: https://goo.gl/4QN1CT
Amazon US: http://amzn.to/2DyyYYa
Amazon Germany : http://amzn.to/2DyBtd1

Raspberry Pi

Banggood: https://goo.gl/wrcUS3
Amazon US: http://amzn.to/2Dw3oKT
Amazon Germany : http://amzn.to/2FUW5Sj

Female to Female Jumper Cable Wires 20cm

Banggood: https://goo.gl/E93MCh
Amazon US: http://amzn.to/2FISFmg
Amazon Germany: http://amzn.to/2pkj27N

Hardware connection:

Once you have you required hardware ready you need to start connecting them. Refer here for interfacing the keypad with Raspberrry pi.  Now if you have gone thorough  the link and connected the keypad, then only thing left is the speaker. I used a 3.5mm jack based speaker, while other may use a HDMI one. I leave it your choice of hardware availability.

Application:

The application is written using python language and it uses pad4pi keypad library for interfacing keypad and pygame mixer for playing sounds.

$ git clone https://github.com/codelectron/Soundboard

Before starting the application you need to install the dependancies of the application.

pip install pad4pi
pip install pygame

 Now the application is ready for playing let me explain the source code firstly.

Code explanation

# Setup Keypad
KEYPAD = [
[“1″,”2″,”3”],
[“4″,”5″,”6”],
[“7″,”8″,”9”],
[“*”,”0″,”#”]
]

Here the keypad is defined for future reference lookup. whenever key is pressed this array will be looked up and the value will be returned.

ROW_PINS = [11,23,24,25] # BCM numbering

This single dimension array consist of pins connected to the row of the keypad.
COL_PINS = [17,27,22] # BCM numbering

This single dimension array consist of pins connected to the column of the keypad.
mixer.init()

This is the pygame mixer initialisation which is required before we start using the mixer for playing tones.
factory = rpi_gpio.KeypadFactory()

This is the template factory object that we need to create in order to make a new keypad.
keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

Here we create a keypad handler with the above defined characteristics.
keypad.registerKeyPressHandler(processKey)

Here we pass the interrupt handler to process key.
#raw_input(“Press Enter to continue…”)
while 1:
    time.sleep(10)
    keypad.cleanup()

Before we end the application we need to exit the keypad module clean that is done using the cleanup function.

The rest is all condition to decide which tone to play.

def playSound(path):
    mixer.music.stop()
    mixer.music.load(path)
    mixer.music.play()

This function takes a wav/mp3 file path as parameter and stop the mixer if it is already playing and then load the new file and play it. All what I have written here have been explained by me in this video

 

Leave a Reply

Your email address will not be published. Required fields are marked *