-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeys.py
38 lines (30 loc) · 1019 Bytes
/
keys.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
import os
from musthe import Note, Interval, scale
NOTES = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
ALTERATIONS = ['', 'b', '#']
for n in NOTES:
for alt in ALTERATIONS:
note = Note(n+alt)
minor_relative = note + Interval('M6')
alt_name = 'natural'
if alt == 'b':
alt_name = 'flat'
elif alt == '#':
alt_name = 'sharp'
tag = '-'.join(['key', alt_name])
file_name = '-'.join([n, alt_name, 'major'])+'.png'
file_path = os.getcwd()+'/keys/'+file_name
img_html = '<img src="'+file_name+'"/>'
if not os.path.exists(file_path):
continue
# Front img / back scale
back = '<h1>'+str(note)+' major / '+str(minor_relative)+' minor</h1>'
tags = ' '.join([tag, 'key-img'])
print '\t'.join([img_html, back, tags])
# Front scale / back img
front = '<h1>'+str(note)+' major</h1>'
tags = ' '.join([tag, 'key-major'])
print '\t'.join([front, img_html, tags])
front = '<h1>'+str(minor_relative)+' minor</h1>'
tags = ' '.join([tag, 'key-minor'])
print '\t'.join([front, img_html, tags])