-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnv.py
132 lines (129 loc) · 2.52 KB
/
cnv.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
filein = open('convert.txt', 'r').read()
fileout = open('converted.txt', 'a')
i = 0
for word in filein.split():
i += 1
if i % 3 == 2:
fileout.write(word[:-3])
fileout.write(',')
if i % 3 == 1:
fileout.write(f'"{word}":')
if i%3 == 0:
fileout.write('\n\t')
#THIS APPENDS SO MUST USE ONLY ONE TIME WITH FILE EMPTY
my_dict = {
"C0": 16,
"C#0/Db0": 17,
"D0": 18,
"D#0/Eb0": 19,
"E0": 20,
"F0": 21,
"F#0/Gb0": 23,
"G0": 24,
"G#0/Ab0": 25,
"A0": 27,
"A#0/Bb0": 29,
"B0": 30,
"C1": 32,
"C#1/Db1": 34,
"D1": 36,
"D#1/Eb1": 38,
"E1": 41,
"F1": 43,
"F#1/Gb1": 46,
"G1": 49,
"G#1/Ab1": 51,
"A1": 55,
"A#1/Bb1": 58,
"B1": 61,
"C2": 65,
"C#2/Db2": 69,
"D2": 73,
"D#2/Eb2": 77,
"E2": 82,
"F2": 87,
"F#2/Gb2": 92,
"G2": 98,
"G#2/Ab2": 103,
"A2": 110,
"A#2/Bb2": 116,
"B2": 123,
"C3": 130,
"C#3/Db3": 138,
"D3": 146,
"D#3/Eb3": 155,
"E3": 164,
"F3": 174,
"F#3/Gb3": 185,
"G3": 196,
"G#3/Ab3": 207,
"A3": 220,
"A#3/Bb3": 233,
"B3": 246,
"C4": 261,
"C#4/Db4": 277,
"D4": 293,
"D#4/Eb4": 311,
"E4": 329,
"F4": 349,
"F#4/Gb4": 369,
"G4": 392,
"G#4/Ab4": 415,
"A4": 440,
"A#4/Bb4": 466,
"B4": 493,
"C5": 523,
"C#5/Db5": 554,
"D5": 587,
"D#5/Eb5": 622,
"E5": 659,
"F5": 698,
"F#5/Gb5": 739,
"G5": 783,
"G#5/Ab5": 830,
"A5": 880,
"A#5/Bb5": 932,
"B5": 987,
"C6": 1046,
"C#6/Db6": 1108,
"D6": 1174,
"D#6/Eb6": 1244,
"E6": 1318,
"F6": 1396,
"F#6/Gb6": 1479,
"G6": 1567,
"G#6/Ab6": 1661,
"A6": 1760,
"A#6/Bb6": 1864,
"B6": 1975,
"C7": 2093,
"C#7/Db7": 2217,
"D7": 2349,
"D#7/Eb7": 2489,
"E7": 2637,
"F7": 2793,
"F#7/Gb7": 2959,
"G7": 3135,
"G#7/Ab7": 3322,
"A7": 3520,
"A#7/Bb7": 3729,
"B7": 3951,
"C8": 4186,
"C#8/Db8": 4434,
"D8": 4698,
"D#8/Eb8": 4978,
"E8": 5274,
"F8": 5587,
"F#8/Gb8": 5919,
"G8": 6271,
"G#8/Ab8": 6644,
"A8": 7040,
"A#8/Bb8": 7458,
"B8": 7902,
}
key_list = list(my_dict.keys())
val_list = list(my_dict.values())
unprocessed_value = 7900
aprox_val = min(val_list, key=lambda x:abs(x-unprocessed_value))
#print(aprox_val)
#print(key_list[val_list.index(aprox_val)])