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."""
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue