-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
110 lines (100 loc) · 3.91 KB
/
main.py
File metadata and controls
110 lines (100 loc) · 3.91 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import mingus.core.notes as notes
from progression import Progression
def main():
print("-" * 50)
print("Welcome to Ziya, The Music Theory Assistant")
print("-" * 50)
prog_builder_active = False
prog_analyzer_active = False
# Selector for mode
while True:
message = "Choose Mode: \n1. Chord Progression Builder\n2. Chord Progression Analyzer - In development\n3. Exit\n>>> "
mode = input(message)
if mode not in ["1", "2", "3"]:
print("Invalid option. Please choose 1, 2, or 3.")
continue
if mode == "1":
prog_builder_active = True
print("-" * 50)
print("Chord Progression Builder")
print("-" * 50)
print("You can now add chords to your progression.")
break
if mode == "2":
prog_analyzer_active = True
print("-" * 50)
print("Chord Progression Analyzer")
print("-" * 50)
print("You can now analyze your saved progressions.")
print("Please select a progression.")
break
if mode == "3":
print("Exiting the program.")
return
# Progression Builder
if prog_builder_active:
while True:
select_key = f">>> Select key: "
print("First, select a key for your chord progression.")
current_key = input(select_key)
if current_key == "":
print("No key selected")
continue
if notes.is_valid_note(current_key):
prog = Progression(current_key)
print("\nEnter chords (for example: C, Dm, Gmaj7). Type 'done' when finished.\n")
break
else:
print("Invalid key. Please enter a valid musical key (e.g., C, D, E, etc.).")
triads = prog.get_natural_triads()
print("Suggested chords based on the key:")
print(f"{triads}")
while True:
print(f"\n>>> Current progression: {prog.get_current_chord_progression()}\nCurrent key: {current_key}")
enter_chord = f"\nEnter chord name: "
user_input = input(enter_chord)
if user_input.lower() == 'done':
print("Chord progression complete!\n")
break
if prog.add_chord(user_input):
print("\nSuggested chords based on previous chord:")
prog.suggest_chords()
if prog.chords:
print("-" * 25)
print("Final Progression:")
print("-" * 25)
print("Progression (Chords):", prog.chords)
print("Key:", prog.key)
print(f"\nCadence: {prog.get_cadence()[0]}")
print(prog.get_emotional_arc())
while True:
save_message = "Do you want to save this progression? (y/n)\n>>> "
save_input = input(save_message).strip().lower()
if save_input not in ["y", "n"]:
print("Invalid input. Please choose 'y' or 'n'.")
continue
if save_input == "y":
prog.save_progression()
else:
print("Progression not saved")
break
# Progression Analyzer
if prog_analyzer_active:
prog = Progression()
prog.select_progression()
if not prog.chords:
print("No progression was selected. Exiting Progression Analyzer")
return
while True:
msg = "Select report: \n1. General Report\n2. Scale Comparison - In development \n3. Exit\n>>> "
report = input(msg)
if report not in ["1", "2", "3"]:
print("Invalid option. Please choose 1, 2, or 3.")
continue
if report == "1":
prog.general_report()
return
else:
return
if __name__ == "__main__":
main()