Terence Im
Beat Loops for Improv
Source Code (main.py)
from tkinter import *
import pygame
"""
Copyright 2023 Terence Im (born Tae Joon Kim)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class BeatLoopsApp:
def __init__(self, root):
self.root = root
self.root.title("Beat Loops for Improv")
self.root.geometry("1900x960")
self.root.configure(bg="white")
self.track = StringVar()
self.primary_btn_color = "#00FFDD"
pygame.mixer.init()
self.current_beat = pygame.mixer.Sound('Patterns/Pattern 1.wav')
#title and description
self.description = f"Time signature: 4/4\n\nBPM: 90\n\nLength of each beat: 5 min.s\n\n\n\nApp and beats by Terence Im"
self.description_display = Label(text= self.description, fg="black", bg="white", font=("Helvetica", 14), justify="left", bd=0)
self.description_display.grid(row=0, column=0, padx=48, pady=210, sticky="n")
self.app_title_border = LabelFrame(self.root, bg="white", width=670, height=85, bd=5)
self.app_title_border.grid(row=0, column=1, padx=188, pady=50, sticky="n")
self.app_title = Label(self.app_title_border, text="BEAT LOOPS FOR IMPROV", fg=self.primary_btn_color, bg="white", font=("Helvetica", 20), bd=0)
self.app_title.grid(row=0, column=0, padx=73, pady=12)
#stop button
#self.current_beat_name = "[PLEASE SELECT A BEAT.]"
#self.display_current_beat_name_text = "PLAYING: " + self.current_beat_name
self.button_size = {"width": "3", "font": "27"}
self.stop_btn_frame = LabelFrame(self.root, bg="white", width=483, height=250, bd=0)
self.stop_btn_frame.grid(row=0, column=2, padx=25, pady=225, sticky="n")
self.stop_btn = Button(self.stop_btn_frame, text="STOP", bg="white", fg=self.primary_btn_color, font=("Helvetica", 15), width=5,height=2, relief="groove", command=self.StopPlaying)
self.stop_btn.grid(row=0, column=0, padx=0, pady=0)
#list of patterns
self.patterns_list1 = LabelFrame(self.root, bg="white", width=290, height=750, bd=5)
self.patterns_list1.grid(row=0, column=1, padx=0, pady=205, sticky="n")
self.pattern1_btn = Button(self.patterns_list1, text="1", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern1)
self.pattern1_btn.grid(row=0, column=0, padx=20, pady=10)
self.pattern2_btn = Button(self.patterns_list1, text="2", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern2)
self.pattern2_btn.grid(row=0, column=1, padx=20, pady=10)
self.pattern3_btn = Button(self.patterns_list1, text="3", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern3)
self.pattern3_btn.grid(row=0, column=2, padx=20, pady=10)
self.pattern4_btn = Button(self.patterns_list1, text="4", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern4)
self.pattern4_btn.grid(row=0, column=3, padx=20, pady=10)
self.pattern5_btn = Button(self.patterns_list1, text="5", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern5)
self.pattern5_btn.grid(row=0, column=4, padx=20, pady=10)
self.patterns_list2 = LabelFrame(self.root, bg="white", width=290, height=750, bd=5)
self.patterns_list2.grid(row=0, column=1, padx=0, pady=380, sticky="n")
self.pattern6_btn = Button(self.patterns_list2, text="6", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern6)
self.pattern6_btn.grid(row=0, column=0, padx=20, pady=10)
self.pattern7_btn = Button(self.patterns_list2, text="7", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern7)
self.pattern7_btn.grid(row=0, column=1, padx=20, pady=10)
self.pattern8_btn = Button(self.patterns_list2, text="8", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern8)
self.pattern8_btn.grid(row=0, column=2, padx=20, pady=10)
self.pattern9_btn = Button(self.patterns_list2, text="9", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern9)
self.pattern9_btn.grid(row=0, column=3, padx=20, pady=10)
self.pattern10_btn = Button(self.patterns_list2, text="10", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern10)
self.pattern10_btn.grid(row=0, column=4, padx=20, pady=10)
self.patterns_list3 = LabelFrame(self.root, bg="white", width=290, height=750, bd=5)
self.patterns_list3.grid(row=0, column=1, padx=0, pady=555, sticky="n")
self.pattern11_btn = Button(self.patterns_list3, text="11", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern11)
self.pattern11_btn.grid(row=0, column=0, padx=20, pady=10)
self.pattern12_btn = Button(self.patterns_list3, text="12", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern12)
self.pattern12_btn.grid(row=0, column=1, padx=20, pady=10)
self.pattern13_btn = Button(self.patterns_list3, text="13", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern13)
self.pattern13_btn.grid(row=0, column=2, padx=20, pady=10)
self.pattern14_btn = Button(self.patterns_list3, text="14", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern14)
self.pattern14_btn.grid(row=0, column=3, padx=20, pady=10)
self.pattern15_btn = Button(self.patterns_list3, text="15", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern15)
self.pattern15_btn.grid(row=0, column=4, padx=20, pady=10)
self.patterns_list4 = LabelFrame(self.root, bg="white", width=290, height=750, bd=5)
self.patterns_list4.grid(row=0, column=1, padx=0, pady=730, sticky="n")
self.pattern16_btn = Button(self.patterns_list4, text="16", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern16)
self.pattern16_btn.grid(row=0, column=0, padx=20, pady=10)
self.pattern17_btn = Button(self.patterns_list4, text="17", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern17)
self.pattern17_btn.grid(row=0, column=1, padx=20, pady=10)
self.pattern18_btn = Button(self.patterns_list4, text="18", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern18)
self.pattern18_btn.grid(row=0, column=2, padx=20, pady=10)
self.pattern19_btn = Button(self.patterns_list4, text="19", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern19)
self.pattern19_btn.grid(row=0, column=3, padx=20, pady=10)
self.pattern20_btn = Button(self.patterns_list4, text="20", bg="white", fg=self.primary_btn_color, font=("Helvetica", self.button_size["font"]), width=self.button_size["width"], relief="groove", command=self.PlayPattern20)
self.pattern20_btn.grid(row=0, column=4, padx=20, pady=10)
self.copyright_notice = Label(self.root, text="Copyright © 2023 by Terence Im (born Tae Joon Kim)", bg="white", fg="black", font=("Helvetica", 12))
self.copyright_notice.grid(row=0, column=1, padx=0, pady=910)
def StopPlaying(self):
self.current_beat.stop()
def PlayPattern1(self):
self.current_beat.stop()
self.pattern1 = pygame.mixer.Sound('Patterns/Pattern 1.wav')
self.current_beat = self.pattern1
if self.current_beat:
self.current_beat.play()
def PlayPattern2(self):
self.current_beat.stop()
self.pattern2 = pygame.mixer.Sound('Patterns/Pattern 2.wav')
self.current_beat = self.pattern2
if self.current_beat:
self.current_beat.play()
def PlayPattern3(self):
self.current_beat.stop()
self.pattern3 = pygame.mixer.Sound('Patterns/Pattern 3.wav')
self.current_beat = self.pattern3
if self.current_beat:
self.current_beat.play()
def PlayPattern4(self):
self.current_beat.stop()
self.pattern4 = pygame.mixer.Sound('Patterns/Pattern 4.wav')
self.current_beat = self.pattern4
if self.current_beat:
self.current_beat.play()
def PlayPattern5(self):
self.current_beat.stop()
self.pattern5 = pygame.mixer.Sound('Patterns/Pattern 5.wav')
self.current_beat = self.pattern5
if self.current_beat:
self.current_beat.play()
def PlayPattern6(self):
self.current_beat.stop()
self.pattern6 = pygame.mixer.Sound('Patterns/Pattern 6.wav')
self.current_beat = self.pattern6
if self.current_beat:
self.current_beat.play()
def PlayPattern7(self):
self.current_beat.stop()
self.pattern7 = pygame.mixer.Sound('Patterns/Pattern 7.wav')
self.current_beat = self.pattern7
if self.current_beat:
self.current_beat.play()
def PlayPattern8(self):
self.current_beat.stop()
self.pattern8 = pygame.mixer.Sound('Patterns/Pattern 8.wav')
self.current_beat = self.pattern8
if self.current_beat:
self.current_beat.play()
def PlayPattern9(self):
self.current_beat.stop()
self.pattern9 = pygame.mixer.Sound('Patterns/Pattern 9.wav')
self.current_beat = self.pattern9
if self.current_beat:
self.current_beat.play()
def PlayPattern10(self):
self.current_beat.stop()
self.pattern10 = pygame.mixer.Sound('Patterns/Pattern 10.wav')
self.current_beat = self.pattern10
if self.current_beat:
self.current_beat.play()
def PlayPattern11(self):
self.current_beat.stop()
self.pattern11 = pygame.mixer.Sound('Patterns/Pattern 11.wav')
self.current_beat = self.pattern11
if self.current_beat:
self.current_beat.play()
def PlayPattern12(self):
self.current_beat.stop()
self.pattern12 = pygame.mixer.Sound('Patterns/Pattern 12.wav')
self.current_beat = self.pattern12
if self.current_beat:
self.current_beat.play()
def PlayPattern13(self):
self.current_beat.stop()
self.pattern13 = pygame.mixer.Sound('Patterns/Pattern 13.wav')
self.current_beat = self.pattern13
if self.current_beat:
self.current_beat.play()
def PlayPattern14(self):
self.current_beat.stop()
self.pattern14 = pygame.mixer.Sound('Patterns/Pattern 14.wav')
self.current_beat = self.pattern14
if self.current_beat:
self.current_beat.play()
def PlayPattern15(self):
self.current_beat.stop()
self.pattern15 = pygame.mixer.Sound('Patterns/Pattern 15.wav')
self.current_beat = self.pattern15
if self.current_beat:
self.current_beat.play()
def PlayPattern16(self):
self.current_beat.stop()
self.pattern16 = pygame.mixer.Sound('Patterns/Pattern 16.wav')
self.current_beat = self.pattern16
if self.current_beat:
self.current_beat.play()
def PlayPattern17(self):
self.current_beat.stop()
self.pattern17 = pygame.mixer.Sound('Patterns/Pattern 17.wav')
self.current_beat = self.pattern17
if self.current_beat:
self.current_beat.play()
def PlayPattern18(self):
self.current_beat.stop()
self.pattern18 = pygame.mixer.Sound('Patterns/Pattern 18.wav')
self.current_beat = self.pattern18
if self.current_beat:
self.current_beat.play()
def PlayPattern19(self):
self.current_beat.stop()
self.pattern19 = pygame.mixer.Sound('Patterns/Pattern 19.wav')
self.current_beat = self.pattern19
if self.current_beat:
self.current_beat.play()
def PlayPattern20(self):
self.current_beat.stop()
self.pattern20 = pygame.mixer.Sound('Patterns/Pattern 20.wav')
self.current_beat = self.pattern20
if self.current_beat:
self.current_beat.play()
root = Tk()
BeatLoopsApp(root)
root.mainloop()