diff --git a/Beat-Board/README.md b/Beat-Board/README.md new file mode 100644 index 0000000000..ea0a1e2328 --- /dev/null +++ b/Beat-Board/README.md @@ -0,0 +1,42 @@ +# Beat Board Script + +This program uses tkinter GUI to create a beat board in +which the user can activate specific sounds based on the +button or key pressed. + +The following keys correspond to the positions of the pads + +|Left Column |Middle Column | Right Column | +|-- |---------- |-------- | +|q |w |e | +|a |s |d | +|z |x |c | + + +## Setup instructions + +This script uses the following modules: + +* tkinter +* playsound + * To install module run the following command: `pip install playsound` +* Thread from threading + + +To run the script follow the following steps: + +1. Make sure you are within the Amazing-Python-Script directory +2. Run the following command `python Beat-Board/beatBoard.py` + +## Detailed explanation of script, if needed + +This script uses a class-based approach to organize the different pads that +can be seen in the GUI. This class contains the functions from the playsound module. The rest of the code is creating the buttons and linking the sounds with their respective objects. + +## Output + +Display images/gifs/videos of output/result of your script so that users can visualize it + +## Author + +Albert Paez diff --git a/Beat-Board/Sounds/Kick.wav b/Beat-Board/Sounds/Kick.wav new file mode 100644 index 0000000000..90e548e291 Binary files /dev/null and b/Beat-Board/Sounds/Kick.wav differ diff --git a/Beat-Board/Sounds/Pad1.wav b/Beat-Board/Sounds/Pad1.wav new file mode 100644 index 0000000000..f27dd8567f Binary files /dev/null and b/Beat-Board/Sounds/Pad1.wav differ diff --git a/Beat-Board/Sounds/Pad2.wav b/Beat-Board/Sounds/Pad2.wav new file mode 100644 index 0000000000..04ea675132 Binary files /dev/null and b/Beat-Board/Sounds/Pad2.wav differ diff --git a/Beat-Board/Sounds/Pad3.wav b/Beat-Board/Sounds/Pad3.wav new file mode 100644 index 0000000000..8810709f45 Binary files /dev/null and b/Beat-Board/Sounds/Pad3.wav differ diff --git a/Beat-Board/Sounds/Pad4.wav b/Beat-Board/Sounds/Pad4.wav new file mode 100644 index 0000000000..82f1e904d7 Binary files /dev/null and b/Beat-Board/Sounds/Pad4.wav differ diff --git a/Beat-Board/Sounds/Pad5.wav b/Beat-Board/Sounds/Pad5.wav new file mode 100644 index 0000000000..f7b74fb3c1 Binary files /dev/null and b/Beat-Board/Sounds/Pad5.wav differ diff --git a/Beat-Board/Sounds/Pad6.wav b/Beat-Board/Sounds/Pad6.wav new file mode 100644 index 0000000000..53512bbf93 Binary files /dev/null and b/Beat-Board/Sounds/Pad6.wav differ diff --git a/Beat-Board/Sounds/hiHat.wav b/Beat-Board/Sounds/hiHat.wav new file mode 100644 index 0000000000..fe5216e5a0 Binary files /dev/null and b/Beat-Board/Sounds/hiHat.wav differ diff --git a/Beat-Board/Sounds/snare.wav b/Beat-Board/Sounds/snare.wav new file mode 100644 index 0000000000..16fb6f8409 Binary files /dev/null and b/Beat-Board/Sounds/snare.wav differ diff --git a/Beat-Board/beatBoard.py b/Beat-Board/beatBoard.py new file mode 100644 index 0000000000..6da0c34c06 --- /dev/null +++ b/Beat-Board/beatBoard.py @@ -0,0 +1,117 @@ +from tkinter import * +from playsound import playsound +from threading import Thread + + +class padSound: + def __init__(self, soundLocation): + self.soundLocation = soundLocation + + def given_sound(self): + playsound(self.soundLocation) + + def play_sound(self,event): + sound = Thread(target=self.given_sound) + sound.start() + + +# All the locations of the sounds +kickLocation = './Beat-Board/Sounds/Kick.wav' +hiHatLocation = './Beat-Board/Sounds/hiHat.wav' +snareLocation = './Beat-Board/Sounds/snare.wav' +pad1Location = './Beat-Board/Sounds/Pad1.wav' +pad2Location = './Beat-Board/Sounds/Pad2.wav' +pad3Location = './Beat-Board/Sounds/Pad3.wav' +pad4Location = './Beat-Board/Sounds/Pad4.wav' +pad5Location = './Beat-Board/Sounds/Pad5.wav' +pad6Location = './Beat-Board/Sounds/Pad6.wav' + +# Create drum objects +kickDrum = padSound(kickLocation) +hiHatDrum = padSound(hiHatLocation) +snareDrum = padSound(snareLocation) + +# Create pad objects +pad1 = padSound(pad1Location) +pad2 = padSound(pad2Location) +pad3 = padSound(pad3Location) +pad4 = padSound(pad4Location) +pad5 = padSound(pad5Location) +pad6 = padSound(pad6Location) + +def create_layout(): + + # Creates the Frame + frame_a = Frame(master=main_window, width=500, height=500, bg="black") + frame_a.grid(rowspan=3, columnspan=3) + frame_a.focus_set() + + # Creates the Buttons + # ------------------------------------------------ + # Kick Button + kickButton = Button(text="Kick", height=5, width=10) + frame_a.bind('q', kickDrum.play_sound) + kickButton.bind("", kickDrum.play_sound) + + # Hi-hat Button + hihatButton = Button(text="Hi-Hat", height=5, width=10) + frame_a.bind('w', hiHatDrum.play_sound) + hihatButton.bind("", hiHatDrum.play_sound) + + # Snare Button + snareButton = Button(text="Snare", height=5, width=10) + frame_a.bind('e', snareDrum.play_sound) + snareButton.bind("", snareDrum.play_sound) + + # ------------------------------------------------- + # Pad 1 + pad1Button = Button(text="Pad 1", height=5, width=10) + frame_a.bind('a', pad1.play_sound) + pad1Button.bind("", pad1.play_sound) + + # Pad 2 + pad2Button = Button(text="Pad 2", height=5, width=10) + frame_a.bind('s', pad2.play_sound) + pad2Button.bind("", pad2.play_sound) + + # Pad 3 + pad3Button = Button(text="Pad 3", height=5, width=10) + frame_a.bind('d', pad3.play_sound) + pad3Button.bind("", pad2.play_sound) + + # ------------------------------------------------- + # Pad 4 + pad4Button = Button(text="Pad 4", height=5, width=10) + frame_a.bind('z', pad4.play_sound) + pad4Button.bind("", pad4.play_sound) + + # Pad 5 + pad5Button = Button(text="Pad 5", height=5, width=10) + frame_a.bind('x', pad5.play_sound) + pad5Button.bind("", pad5.play_sound) + + # Pad 6 + pad6Button = Button(text="Pad 6", height=5, width=10) + frame_a.bind('c', pad6.play_sound) + pad6Button.bind("", pad6.play_sound) + # ------------------------------------------------- + + # Display Buttons + kickButton.grid(row=0) + hihatButton.grid(row=0, column=1) + snareButton.grid(row=0, column=2) + + pad1Button.grid(row=1) + pad2Button.grid(row=1, column=1) + pad3Button.grid(row=1, column=2) + + pad4Button.grid(row=2) + pad5Button.grid(row=2, column=1) + pad6Button.grid(row=2, column=2) + + +main_window = Tk() +main_window.resizable(False,False) +main_window.title('Beat Board') +create_layout() +main_window.mainloop() diff --git a/Beat-Board/requirements.txt b/Beat-Board/requirements.txt new file mode 100644 index 0000000000..c70c4434cc --- /dev/null +++ b/Beat-Board/requirements.txt @@ -0,0 +1 @@ +playsound==1.2.2