From 42aa7798d241457b70f3901f78d440f31c2726a2 Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Sat, 4 Apr 2026 19:57:54 +0200 Subject: [PATCH] Simplify play-siren: remove unused frequency+voice mode --- webapp/server.py | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/webapp/server.py b/webapp/server.py index bd1a7cc..3556675 100644 --- a/webapp/server.py +++ b/webapp/server.py @@ -130,36 +130,23 @@ def play_siren(): """Play a single frequency for a node on the siren.""" data = request.json - # Support two modes: - # 1. chordIndex + nodeIndex (from clicking a single node) - # 2. frequency + voice (from clicking a chord label) chord_index = data.get("chordIndex") node_index = data.get("nodeIndex") - frequency = data.get("frequency") - voice = data.get("voice") - if frequency is None and voice is None: - # Mode 1: use chordIndex/nodeIndex - if chord_index is None or node_index is None: - return jsonify( - {"error": "Missing chordIndex/nodeIndex or frequency/voice"} - ), 400 + if chord_index is None or node_index is None: + return jsonify({"error": "Missing chordIndex/nodeIndex"}), 400 - if chord_index < 0 or chord_index >= len(chords): - return jsonify({"error": "Invalid chord index"}), 400 + if chord_index < 0 or chord_index >= len(chords): + return jsonify({"error": "Invalid chord index"}), 400 - chord = chords[chord_index] - if node_index < 0 or node_index >= len(chord): - return jsonify({"error": "Invalid node index"}), 400 + chord = chords[chord_index] + if node_index < 0 or node_index >= len(chord): + return jsonify({"error": "Invalid node index"}), 400 - pitch = chord[node_index] - fraction = Fraction(pitch.get("fraction", "1")) - frequency = fundamental * float(fraction) - voice = node_index + 1 # 1-indexed - else: - # Mode 2: use provided frequency/voice - if frequency is None or voice is None: - return jsonify({"error": "Missing frequency or voice"}), 400 + pitch = chord[node_index] + fraction = Fraction(pitch.get("fraction", "1")) + frequency = fundamental * float(fraction) + voice = node_index + 1 # 1-indexed # Send to siren (192.168.4.200:54001) using current fundamental siren_sender = OSCSender(ip="192.168.4.200", port=54001, fundamental=fundamental)