-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrandomNotesUpAndDownFretboard.py
75 lines (60 loc) · 2.05 KB
/
randomNotesUpAndDownFretboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from random import shuffle
from time import sleep
import platform
import sys
import random
from enum import Enum
if platform.system() == "Windows":
import winsound
class Pattern(Enum):
upDown = "1"
up = "2"
down = "3"
random = "4"
def getStrings(self):
if self == Pattern.upDown:
stringsInReverse = strings[::-1][1:-1]
return strings + stringsInReverse
elif self == Pattern.up:
return strings
elif self == Pattern.down:
return strings[::-1]
elif self == Pattern.random:
return random.sample(strings, len(strings))
def printStrings(note, currentString):
for _ in range(6):
sys.stdout.write("\033[F")
for string in strings[::-1]:
if string == currentString:
if len(note) == 2:
print(string + "|-" + note + "-|")
else:
print(string + "|-" + note + "--|")
else:
print(string + "|----|")
metronomeFrequency = 2000 # 2000 Hertz
metronomeDuration = 100 # 100 ms == 0.1 second
bpm = 40
secondsPerBeat = 60 / bpm
reps = 8 # number of times to drill
strings = ["E", "A", "D", "G", "B", "e"]
pattern = Pattern.random
# notes = ["A", "B", "C", "D", "E", "F", "G"] # natural notes
# notes = ["Ab", "Bb", "Db", "Eb", "Gb"] # flats
# notes = ["A#", "C#", "D#", "F#", "G#"] # sharps
notes = ["A", "B", "C", "D", "E", "F", "G", "Ab", "Bb", "Db", "Eb", "Gb", "A#", "C#", "D#", "F#", "G#"]
# short pause to get read
sleep(2) # seconds
for _ in range(6):
print()
for _ in range(reps):
for currentString in pattern.getStrings():
shuffle(notes)
printStrings(notes[0], currentString)
if platform.system() == "Windows":
sleep(secondsPerBeat - (metronomeDuration / 1000))
winsound.Beep(metronomeFrequency, metronomeDuration)
else:
# I'm guessing the sound caused by printing '\a' is asynchronous? This might screw up the metronome on Mac/Linux
sleep(secondsPerBeat)
print('\a')