asigalov61 commited on
Commit
e47b702
1 Parent(s): f2c28d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -94,22 +94,34 @@ def mix_chord(chord, tones_chord, mel_patch, mel_pitch, next_note_dtime):
94
 
95
  tclen = len(tones_chord)
96
 
97
- tchord = tones_chord
 
 
 
 
 
 
98
 
99
  if len(cg) > tclen:
100
  tchord = tones_chord + [random.choice(tones_chord) for _ in range(len(cg)-tclen)]
101
 
 
 
102
  for i, cc in enumerate(cg):
 
 
103
 
104
- c = copy.deepcopy(cc)
105
-
106
- if cc[2] > next_note_dtime:
107
- c[2] = next_note_dtime
108
-
109
- c[4] = ((c[4] // 12) * 12) + tchord[i]
110
- c[5] += c[4] % 12
111
-
112
- cho.append(c)
 
 
113
 
114
  else:
115
  cho.extend(list(g))
 
94
 
95
  tclen = len(tones_chord)
96
 
97
+ tchord = []
98
+
99
+ if len(tones_chord) == 1:
100
+ tchord = sorted(tones_chord + [tones_chord[0] + 7])
101
+
102
+ else:
103
+ tchord = tones_chord
104
 
105
  if len(cg) > tclen:
106
  tchord = tones_chord + [random.choice(tones_chord) for _ in range(len(cg)-tclen)]
107
 
108
+ seen = []
109
+
110
  for i, cc in enumerate(cg):
111
+
112
+ if [cc[4], cc[6]] not in seen:
113
 
114
+ c = copy.deepcopy(cc)
115
+
116
+ if cc[2] > next_note_dtime:
117
+ c[2] = next_note_dtime
118
+
119
+ c[4] = ((c[4] // 12) * 12) + tchord[i]
120
+ c[5] += c[4] % 12
121
+
122
+ cho.append(c)
123
+
124
+ seen.append([cc[4], cc[6]])
125
 
126
  else:
127
  cho.extend(list(g))