Add place.py

This commit is contained in:
Thibaud 2024-05-05 11:14:49 +02:00
parent d899f72602
commit 44cd612cfc
1 changed files with 42 additions and 0 deletions

42
place.py Normal file
View File

@ -0,0 +1,42 @@
import numpy as np
"""
whle
"""
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