From 44cd612cfc54ce66fc5877571cd9e6e5f144a07a Mon Sep 17 00:00:00 2001 From: Thibaud Date: Sun, 5 May 2024 11:14:49 +0200 Subject: [PATCH] Add place.py --- place.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 place.py diff --git a/place.py b/place.py new file mode 100644 index 0000000..227e23e --- /dev/null +++ b/place.py @@ -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 + + + +