Making progress on chord generation

This commit is contained in:
Dionysus 2023-05-18 20:29:41 -04:00
parent 703aacb1d5
commit 400703d72f
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
8 changed files with 26 additions and 11 deletions

View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 168 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,9 +1,9 @@
# mzk # mzk
> music theory helper > music theory helper
![](screens/circle.png) ![](.screens/circle.png)
![](screens/intervals_scales.png) ![](.screens/intervals_scales.png)
![](screens/scale.png) ![](.screens/scale.png)
## Information ## Information
This repository originally started off as a means of using Python to learn music theory, specifcally guitar theory, since the basis of musical sound can be described mathematically *(in acoustics)* and exhibits a remarkable array of number properties. This repository originally started off as a means of using Python to learn music theory, specifcally guitar theory, since the basis of musical sound can be described mathematically *(in acoustics)* and exhibits a remarkable array of number properties.
@ -27,7 +27,7 @@ Using the root of C, we can apply the pattern of the major scale to the C chroma
* Scale/chord ASCII coloring * Scale/chord ASCII coloring
## Mirrors ## Mirrors
- [acid.vegas](https://acid.vegas/mzk) - [acid.vegas](https://git.acid.vegas/mzk)
- [GitHub](https://github.com/acidvegas/mzk) - [GitHub](https://github.com/acidvegas/mzk)
- [GitLab](https://gitlab.com/acidvegas/mzk) - [GitLab](https://gitlab.com/acidvegas/mzk)
- [SuperNETs](https://git.supernets.org/acidvegas/mzk) - [SuperNETs](https://git.supernets.org/acidvegas/mzk)

Binary file not shown.

Binary file not shown.

View File

@ -28,6 +28,20 @@ def get_pattern(pattern):
elif step == '3' : new_pattern.append('WH') elif step == '3' : new_pattern.append('WH')
return ' '.join(new_pattern) return ' '.join(new_pattern)
def chord_notes(type, key):
notes = scale_notes(type, key)
pattern = constants.chords[type]['pattern']
_notes = [key,]
for step in pattern.split()[1:]: #1 b3 5
if len(step) == 2:
if step[:1] == 'b':
_notes.append(notes[int(step)-2])
elif step[:1] == '#':
_notes.append(notes[int(step)])
else:
_notes.append(notes[int(step)-1])
return _notes
def scale_notes(type, key): def scale_notes(type, key):
last = 0 last = 0
all_notes = chromatic_scale(key)*2 all_notes = chromatic_scale(key)*2
@ -146,13 +160,13 @@ def print_intervals():
print('└───────────┴────────────────────┴───────┘') print('└───────────┴────────────────────┴───────┘')
print(print_intervals.__doc__) print(print_intervals.__doc__)
def print_scale(root, type, full=False): def print_scale(root, type, full=False, chord=False):
frets = (24,147) if full else (12,75) frets = (24,147) if full else (12,75)
print(f'{root.upper()} {type.upper()} SCALE'.center(frets[1])) print(f'{root.upper()} {type.upper()} SCALE'.center(frets[1]))
print('' + ''.join(''*5 for x in range(frets[0])) + '') print('' + ''.join(''*5 for x in range(frets[0])) + '')
print('0 │' + ''.join(str(x).center(5) for x in range(1,frets[0]+1)) + '') print('0 │' + ''.join(str(x).center(5) for x in range(1,frets[0]+1)) + '')
print('' + ''.join(''*5 for x in range(frets[0])) + '') print('' + ''.join(''*5 for x in range(frets[0])) + '')
notes = scale_notes(type, root) notes = chord_notes(type, root) if chord else scale_notes(type, root)
for string in ('eBGDAE'): for string in ('eBGDAE'):
string_notes = generate_scale_string(string, notes, full) string_notes = generate_scale_string(string, notes, full)
print(string + '' + ''.join(note.center(5, '-') for note in string_notes[1:]) + '') print(string + '' + ''.join(note.center(5, '-') for note in string_notes[1:]) + '')

View File

@ -12,17 +12,18 @@ import functions
if len(sys.argv) != 2: if len(sys.argv) != 2:
functions.print_help() functions.print_help()
else: else:
if sys.argv[1].startswith('--chord='): print(sys.argv[1])
if sys.argv[1] == '--chords':
functions.print_chords()
elif sys.argv[1].startswith('--chord='):
chord = sys.argv[1][8:] chord = sys.argv[1][8:]
key = chord.split('_')[0].upper() key = chord.split('_')[0].upper()
type = chord[len(key)+1:].lower() type = chord[len(key)+1:].lower()
if key in constants.notes and type in constants.scales: if key in constants.notes and type in constants.chords:
functions.print_chord(key, type) functions.print_scale(key, type, chord=True)
else: else:
print('error: invalid key or chord type\n\n') print('error: invalid key or chord type\n\n')
functions.print_help() functions.print_help()
elif sys.argv[1] == '--chords':
functions.print_chords()
elif sys.argv[1] == '--circle': elif sys.argv[1] == '--circle':
functions.print_circle_of_fifths() functions.print_circle_of_fifths()
elif sys.argv[1] == '--intervals': elif sys.argv[1] == '--intervals':