Created
September 26, 2013 18:19
-
-
Save lonetwin/6718319 to your computer and use it in GitHub Desktop.
Python functions to generate the names of the notes for various musical scales, meant to be used for quick reference when practising the guitar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
notes = ['a', 'a#', 'b', 'c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#'] * 2 | |
chroma = lambda x: [ i for i in notes[ notes.index(x): ] + notes[ :notes.index(x) ] ] + [x] | |
major = lambda x: ( chroma(x)[:5] + [chroma(x)[5]] + chroma(x)[5:12] )[::2] + [x] | |
major_penta = lambda x: [ i for idx, i in enumerate(major(x)) if idx not in (3, 6) ] | |
minor_penta = lambda x: ( major_penta( notes[ notes.index(x) + 3 ])[:-1] * 2)[-6:] | |
""" | |
# for example | |
for i in 'abcdefg': | |
print '-------------------------------' | |
print 'Chromatic Scale in %s: %s' % (i, ', '.join(chroma(i)[:13])) | |
print 'Major Scale in %s: %s' % (i, ', '.join(major(i))) | |
print 'Major Pentatonic Scale in %s: %s' % (i, ', '.join(major_penta(i))) | |
print 'Minor Pentatonic Scale in %s: %s' % (i, ', '.join(minor_penta(i))) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment