From 1a07709d39054a8972970f78b64ef4a66b5684b2 Mon Sep 17 00:00:00 2001 From: Kieran McAuliffe Date: Tue, 9 Sep 2025 10:16:11 +0200 Subject: [PATCH] almost finished gelb --- music_tracker.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/music_tracker.py b/music_tracker.py index c39ef46..03b2cf9 100644 --- a/music_tracker.py +++ b/music_tracker.py @@ -18,7 +18,9 @@ args = parser.parse_args() client = udp_client.SimpleUDPClient(args.ip, args.port) angle = 0 -magnitude = 20 +magnitude = 0 +mean = 74.1 + for msg in mid.tracks[1]: t = mido.tick2second(msg.time, mid.ticks_per_beat, 1000000) @@ -27,13 +29,11 @@ for msg in mid.tracks[1]: rotation = 2 * math.pi * beats / 16 angle += rotation - magnitude += beats - if msg.type != "note_on": + magnitude += beats * 3 + if msg.type != "note_on" or msg.time == 0: continue - print(angle) - print(magnitude) - - y = math.sin(angle) * magnitude - x = math.cos(angle) * magnitude - client.send_message("/tcp_coordinates", (x, y, 10, 0, 0, 0)) + adj_angle = angle + (msg.note - mean) / 9 + y = math.sin(adj_angle) * magnitude + x = math.cos(adj_angle) * magnitude + client.send_message("/tcp_coordinates", (x, y, 6, 0, 0, 0))