Last active
May 4, 2023 20:31
-
-
Save HuangJiaLian/87428af3372b33c183b69993e9ce0bfb to your computer and use it in GitHub Desktop.
Change tempo using the scale
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 | |
scale = tk.Scale(midFrame, | |
from_=tempo_range[0], | |
to= tempo_range[1], | |
orient=tk.HORIZONTAL, | |
length=defaults['scale_length'], | |
showvalue=0, | |
troughcolor = theme_colors['scale_through'], | |
bd = 0, | |
activebackground = theme_colors['text'], | |
bg = theme_colors['label_bg'], | |
sliderlength = 30, | |
font=(theme_fonts[0]), | |
variable=scale_var, | |
command=update) | |
scale.set(defaults['tempo']) | |
scale.pack(side='bottom',fill='both', expand='0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice job Huang.
I have run through previous scripts until this file "9_change_tempo_part.py " , then I had a few errors,
Below are the with error : Cannot find reference '' in 'init.py'
scale_var = tk.IntVar(midFrame)
tempo = scale_var.get()
scale = tk.Scale(.....)
orient=tk.HORIZONTAL
Below are error: global variable 'time_signature' is undefined at the module level
global scale_var, time_signature, interval_ms, tempo
Do you have any suggestions?
Thanks.