48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import numpy as np
|
|
import slider as sl
|
|
from datetime import timedelta
|
|
|
|
def beatify(bpm:float, offset:int, time_ms:int):
|
|
return bpm/60000 * (time_ms - offset)
|
|
|
|
def demusicify(bpm:float, offset:int, beat:int):
|
|
return (beat*60000/bpm) + offset
|
|
|
|
|
|
def f(intensity): return np.pi/2 - np.arctan(2*intensity - 5)
|
|
|
|
def greedy():
|
|
"""
|
|
input: takes Alexandre's note selection / intensity data
|
|
output: list of object type / position
|
|
"""
|
|
flow = 1
|
|
song_beat = 0
|
|
notes = [0 * len(rhythms)]
|
|
for (rhythm, i) in zip(rhythms, range(len(rhythms))):
|
|
song_beat += rhythm.time
|
|
try:
|
|
duration = rhythm.time - rhythms[i + 1].time
|
|
if duration in (1, 2):
|
|
note_type = "cercle"
|
|
elif duration % 2 == 0:
|
|
rhythms.insert(0, f"slider {duration}")
|
|
else:
|
|
rhythms.insert(0, f"reverse_slider {duration}")
|
|
except IndexError:
|
|
note_type = "cercle"
|
|
# TODO mettre à jour flow
|
|
if len(notes) > 2:
|
|
angle = flow * f(rhythm.intensite)
|
|
x1, y1 = notes[i-2].position
|
|
x2, y2 = notes[i-1].position
|
|
old_angle = np.arctan2((y1, y2), (x1, x2))
|
|
x3 = x2 + (intensity * np.cos(angle + old_angle))
|
|
y3 = y2 + (intensity * np.sin(angle + old_angle))
|
|
else:
|
|
pass
|
|
|
|
|
|
|
|
|