Spaces:
Build error
Build error
Create chord_indentifier.py
Browse files- chord_indentifier.py +20 -0
chord_indentifier.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# chord_identifier.py
|
| 2 |
+
from itertools import permutations
|
| 3 |
+
|
| 4 |
+
# Basic chord dictionary (expand as needed)
|
| 5 |
+
CHORDS = {
|
| 6 |
+
frozenset(["C", "E", "G"]): "C Major",
|
| 7 |
+
frozenset(["A", "C#", "E"]): "A Major",
|
| 8 |
+
frozenset(["A", "C", "E"]): "A Minor",
|
| 9 |
+
frozenset(["D", "F#", "A"]): "D Major",
|
| 10 |
+
frozenset(["E", "G#", "B"]): "E Major",
|
| 11 |
+
frozenset(["G", "B", "D"]): "G Major",
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
def identify_chord(notes):
|
| 15 |
+
"""
|
| 16 |
+
Identify chord name from a list of notes.
|
| 17 |
+
Falls back to 'Unknown' if no match is found.
|
| 18 |
+
"""
|
| 19 |
+
key = frozenset([n.upper() for n in notes])
|
| 20 |
+
return CHORDS.get(key, "Unknown Chord")
|