asigalov61 commited on
Commit
143d19a
·
verified ·
1 Parent(s): 4190c66

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md CHANGED
@@ -112,5 +112,66 @@ detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(ms_MIDI_score,
112
 
113
  ***
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  ### Project Los Angeles
116
  ### Tegridy Code 2024
 
112
 
113
  ***
114
 
115
+ ### Calculate MIDI score signature
116
+
117
+ ```python
118
+ import TMIDIX
119
+
120
+ def get_score_signature(midi_score):
121
+
122
+ score = []
123
+
124
+ time = 0
125
+ pt = 0
126
+
127
+ for m in midi_score:
128
+
129
+ if 0 <= m < 128:
130
+ time = m
131
+
132
+ elif 256 < m < 384:
133
+ pitch = (m-256)
134
+
135
+ if time == pt:
136
+ score.append([0, pitch])
137
+ else:
138
+ score.append([time, pitch])
139
+
140
+ pt = time
141
+
142
+ chords = []
143
+ cho = []
144
+
145
+ for s in score:
146
+ if s[0] == 0:
147
+ cho.append(s[1])
148
+
149
+ else:
150
+ if cho:
151
+ chords.append(cho)
152
+
153
+ cho = [s[1]]
154
+
155
+ pitches_chords = []
156
+
157
+ for c in chords:
158
+
159
+ if len(c) > 1:
160
+
161
+ tones_chord = sorted(set([p % 12 for p in c]))
162
+
163
+ while tones_chord not in TMIDIX.ALL_CHORDS_SORTED:
164
+ tones_chord = tones_chord[:-1]
165
+
166
+ pitches_chords.append(TMIDIX.ALL_CHORDS_SORTED.index(tones_chord)+128)
167
+
168
+ else:
169
+ pitches_chords.append(c[0])
170
+
171
+ return list(Counter(pitches_chords).most_common())
172
+ ```
173
+
174
+ ***
175
+
176
  ### Project Los Angeles
177
  ### Tegridy Code 2024