bass clef, and better template
This commit is contained in:
@@ -3,7 +3,8 @@ from __future__ import print_function
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from random import randrange
|
from string import Template
|
||||||
|
from random import randrange, choice
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
@@ -16,7 +17,8 @@ logging.basicConfig(level=logging.INFO)
|
|||||||
|
|
||||||
notes_sharp = ["c", "cis", "d", "dis", "e", "f", "fis", "g", "gis", "a", "ais", "b"]
|
notes_sharp = ["c", "cis", "d", "dis", "e", "f", "fis", "g", "gis", "a", "ais", "b"]
|
||||||
|
|
||||||
lilypond = '''
|
lilypond = Template(
|
||||||
|
'''\\version "2.24.1"
|
||||||
\paper {
|
\paper {
|
||||||
#(set-paper-size "a10landscape")
|
#(set-paper-size "a10landscape")
|
||||||
indent = 0\mm
|
indent = 0\mm
|
||||||
@@ -26,15 +28,18 @@ lilypond = '''
|
|||||||
oddFooterMarkup = ""
|
oddFooterMarkup = ""
|
||||||
evenFooterMarkup = ""
|
evenFooterMarkup = ""
|
||||||
}
|
}
|
||||||
|
\\relative {
|
||||||
'''
|
\clef ${CLEF}
|
||||||
|
${NOTE}
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
|
||||||
window = tk.Tk()
|
window = tk.Tk()
|
||||||
|
|
||||||
class Trainer():
|
class Trainer():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.secret = 0
|
self.secret = 0
|
||||||
self.lb = 60
|
self.lb = 36 # middle C is 60
|
||||||
self.ub = 84 # 108
|
self.ub = 84 # 108
|
||||||
self.image = None
|
self.image = None
|
||||||
self.image_label = tk.Label(window)
|
self.image_label = tk.Label(window)
|
||||||
@@ -45,7 +50,11 @@ class Trainer():
|
|||||||
def newNote(self):
|
def newNote(self):
|
||||||
self.secret = randrange(self.lb, self.ub)
|
self.secret = randrange(self.lb, self.ub)
|
||||||
self.print()
|
self.print()
|
||||||
ly = lilypond + f"{{{self.convertNote(self.secret)}}}"
|
if abs(60 - self.secret) <= 4:
|
||||||
|
clef = choice(["bass", "treble"])
|
||||||
|
else:
|
||||||
|
clef = "bass" if self.secret < 60 else "treble"
|
||||||
|
ly = lilypond.substitute(CLEF=clef, NOTE=f"{{{self.convertNote(self.secret)}}}")
|
||||||
with open("lily.txt", "w") as f:
|
with open("lily.txt", "w") as f:
|
||||||
f.write(ly)
|
f.write(ly)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user