New combo on new measure. Flow change on new combo. Still bad.
This commit is contained in:
parent
568a467a27
commit
0bafd0d899
27
place.py
27
place.py
|
@ -12,23 +12,30 @@ def beatify(bpm:float, offset:int, time:timedelta) -> float:
|
|||
def debeatify(bpm:float, offset:int, beat:int) -> timedelta:
|
||||
return timedelta(milliseconds=(beat*60000/bpm) + offset)
|
||||
|
||||
#def f(intensity): return np.pi/2 - np.arctan(2*intensity) + np.pi/5
|
||||
def f(intensity): return np.pi/2
|
||||
def f(intensity): return np.pi/2 - np.arctan(2*intensity) + np.pi/5
|
||||
#def f(intensity): return np.pi/2
|
||||
|
||||
def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
||||
"""
|
||||
input: takes Alexandre's note selection / intensity data
|
||||
output: list of object type / position
|
||||
"""
|
||||
flow = 1
|
||||
new_combo = True
|
||||
flow = 0
|
||||
notes = [sl.HitObject(sl.Position(260, 188), timedelta(milliseconds=0), 0)] * len(timings)
|
||||
beats = [beatify(bpm, offset, timing) for timing in timings]
|
||||
beats = [int(beatify(bpm, offset, timing)*4) for timing in timings]
|
||||
last_position = (260, 188)
|
||||
max_x, max_y, min_x, min_y = -np.inf, -np.inf, np.inf, np.inf
|
||||
for (delta, note_beat, intensity, i) in zip(timings, beats, amplitudes, range(len(timings))):
|
||||
try:
|
||||
print(notes[i-1].position.x)
|
||||
duration = note_beat - beats[i + 1]
|
||||
if int(note_beat/32) % 2: #test si la mesure est impaire ou non
|
||||
new_combo = not (flow == 1)
|
||||
flow = 1
|
||||
else:
|
||||
new_combo = (flow == 1)
|
||||
flow = -1
|
||||
duration = abs(note_beat - beats[i + 1])
|
||||
print(duration)
|
||||
"""
|
||||
if duration in (QUARTER, HALF):
|
||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||
|
@ -42,7 +49,6 @@ def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
|||
"""
|
||||
except IndexError:
|
||||
notes[i] = sl.Circle(sl.Position(0, 0), delta, 0)
|
||||
# TODO mettre à jour flow
|
||||
|
||||
if len(notes) > 2:
|
||||
if duration == QUARTER:
|
||||
|
@ -54,8 +60,8 @@ def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
|||
x1, y1 = int(notes[i-2].position.x), int(notes[i-2].position.y)
|
||||
x2, y2 = int(notes[i-1].position.x), int(notes[i-1].position.y)
|
||||
old_angle = np.arctan2([y2-y1], [x2-x1])
|
||||
x3 = x2 + (duration*intensity * np.cos(angle + old_angle))
|
||||
y3 = y2 + (duration*intensity * np.sin(angle + old_angle))
|
||||
x3 = x2 + ((duration + new_combo*4)* np.cos(angle + old_angle))
|
||||
y3 = y2 + ((duration + new_combo*4) * np.sin(angle + old_angle))
|
||||
notes[i] = sl.Circle(sl.Position(int(x3[0]), int(y3[0])), delta, 0)
|
||||
else:
|
||||
notes[i] = sl.Circle(sl.Position(260, 188), delta, 0)
|
||||
|
@ -67,11 +73,12 @@ def greedy(bpm:int, offset:int, timings:list, amplitudes:list):
|
|||
max_y = notes[i].position.y
|
||||
elif notes[i].position.y < min_y:
|
||||
min_y = notes[i].position.y
|
||||
|
||||
notes[i].new_combo = new_combo
|
||||
factor_x = 1/(max_x - min_x)
|
||||
factor_y = 1/(max_y - min_y)
|
||||
for note in notes:
|
||||
note.position = sl.Position((note.position.x-min_x)*factor_x*512, (note.position.y-min_y)*factor_y*384)
|
||||
print(note.position.x, note.position.y)
|
||||
|
||||
return notes
|
||||
|
||||
|
|
Loading…
Reference in New Issue