Simplify play-siren: remove unused frequency+voice mode
This commit is contained in:
parent
90f00e56c6
commit
42aa7798d2
|
|
@ -130,36 +130,23 @@ def play_siren():
|
||||||
"""Play a single frequency for a node on the siren."""
|
"""Play a single frequency for a node on the siren."""
|
||||||
data = request.json
|
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")
|
chord_index = data.get("chordIndex")
|
||||||
node_index = data.get("nodeIndex")
|
node_index = data.get("nodeIndex")
|
||||||
frequency = data.get("frequency")
|
|
||||||
voice = data.get("voice")
|
|
||||||
|
|
||||||
if frequency is None and voice is None:
|
if chord_index is None or node_index is None:
|
||||||
# Mode 1: use chordIndex/nodeIndex
|
return jsonify({"error": "Missing chordIndex/nodeIndex"}), 400
|
||||||
if chord_index is None or node_index is None:
|
|
||||||
return jsonify(
|
|
||||||
{"error": "Missing chordIndex/nodeIndex or frequency/voice"}
|
|
||||||
), 400
|
|
||||||
|
|
||||||
if chord_index < 0 or chord_index >= len(chords):
|
if chord_index < 0 or chord_index >= len(chords):
|
||||||
return jsonify({"error": "Invalid chord index"}), 400
|
return jsonify({"error": "Invalid chord index"}), 400
|
||||||
|
|
||||||
chord = chords[chord_index]
|
chord = chords[chord_index]
|
||||||
if node_index < 0 or node_index >= len(chord):
|
if node_index < 0 or node_index >= len(chord):
|
||||||
return jsonify({"error": "Invalid node index"}), 400
|
return jsonify({"error": "Invalid node index"}), 400
|
||||||
|
|
||||||
pitch = chord[node_index]
|
pitch = chord[node_index]
|
||||||
fraction = Fraction(pitch.get("fraction", "1"))
|
fraction = Fraction(pitch.get("fraction", "1"))
|
||||||
frequency = fundamental * float(fraction)
|
frequency = fundamental * float(fraction)
|
||||||
voice = node_index + 1 # 1-indexed
|
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
|
|
||||||
|
|
||||||
# Send to siren (192.168.4.200:54001) using current fundamental
|
# Send to siren (192.168.4.200:54001) using current fundamental
|
||||||
siren_sender = OSCSender(ip="192.168.4.200", port=54001, fundamental=fundamental)
|
siren_sender = OSCSender(ip="192.168.4.200", port=54001, fundamental=fundamental)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue