This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time_list = [] | |
def tap_estimate(): | |
global time_list, scale | |
time_list.append(time.time()) | |
list_len = len(time_list) | |
N = 6 | |
if list_len > 1: | |
# If two time far away from each other | |
# throw away the former times, only left the last one | |
if time_list[-1] - time_list[-2] > 2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ON = True | |
def play(): | |
global count, time_signature, count_label, ON | |
if ON: | |
count += 1 | |
count_label['text'] = '{}'.format(count) | |
if time_signature[0] == -1: | |
strong_beat.play() | |
else: | |
if count == 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def play(): | |
global count, time_signature, count_label | |
count += 1 | |
count_label['text'] = '{}'.format(count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to determine the tempo markings | |
def tempo_marking_of(tempo): | |
for key in markings.keys(): | |
if tempo >= markings[key][0] and tempo <= markings[key][1]: | |
marking = key | |
break | |
else: | |
marking = '' | |
return marking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Variable for the scale value | |
scale_var = tk.IntVar(midFrame) | |
# When scale changes | |
def update(*args): | |
global scale_var, time_signature, interval_ms, tempo | |
tempo = scale_var.get() | |
interval_ms = int((60/tempo) * (4/time_signature[-1]) * 1000) | |
# Use a scale to show the tempo range |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When scale changes | |
def update_interval(*args): | |
global scale_var, time_signature, interval_ms, tempo | |
tempo = scale_var.get() | |
interval_ms = int((60/tempo) * (4/time_signature[-1]) * 1000) | |
scale_var = tk.IntVar(midFrame) | |
# Use a scale to show the tempo range | |
scale = tk.Scale(midFrame, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When time signature mode changes | |
def update_time_signature(*args): | |
global temp, time_signature, count, interval_ms | |
time_signature = time_signatures[ts_mode.get()][-1] | |
interval_ms = int((60/tempo) * (4/time_signature[-1]) * 1000) | |
count = 0 | |
ts_mode.trace('w', update_time_signature) | |
# Time signature selection implementation | |
time_signature = time_signatures[ts_mode.get()][-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Play beats in Tkinter | |
tempo = 120 | |
time_signature = time_signatures[ts_mode.get()][-1] | |
interval_ms = int((60/tempo) * (4/time_signature[-1]) * 1000) | |
def play(): | |
strong_beat.play() | |
window.after(interval_ms, play) | |
window.after(interval_ms, play) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import Frame | |
import simpleaudio, time | |
theme_colors = {'bg': '#52767D', 'text':'#FFFFE6', 'label_bg':'#3D998D', 'scale_through':'#A3CEC5'} | |
theme_fonts = ['Helvetica'] | |
tempo_range = [30, 230] | |
defaults = {'tempo': 120, 'scale_length': 550} | |
# The main window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time_list = [1648565267.9251342, 1648565268.482229, 1648565269.013833, 1648565269.560467, 1648565270.105812, 1648565270.644593, 1648565271.175668] | |
def tempo_estimate(time_list): | |
list_len = len(time_list) | |
N = 6 | |
if list_len < 6: | |
interval = (time_list[-1] - time_list[0]) / (list_len - 1) | |
else: | |
interval = (time_list[-1] - time_list[-N]) / (N - 1) | |
temp = int(60/interval) |