From 2a17339edc669b627ca73f1ae2147039c28e7f53 Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Wed, 1 Apr 2026 18:39:13 +0200 Subject: [PATCH] Add octave offset for play-freq, adjustable via UI input --- webapp/path_navigator.html | 5 ++++- webapp/server.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/path_navigator.html b/webapp/path_navigator.html index f5c8d2b..d069dfd 100644 --- a/webapp/path_navigator.html +++ b/webapp/path_navigator.html @@ -281,6 +281,8 @@ Fundamental (Hz): + Octave: +
@@ -466,7 +468,8 @@ headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ chordIndex: chordIndex, - nodeIndex: localId + nodeIndex: localId, + octave: parseInt(document.getElementById('octaveInput').value) || 0 }) }).then(r => r.json()).then(data => { console.log('Playing on', destination + ':', data.frequency.toFixed(2), 'Hz on voice', data.voice); diff --git a/webapp/server.py b/webapp/server.py index c7659c0..6226889 100644 --- a/webapp/server.py +++ b/webapp/server.py @@ -99,6 +99,7 @@ def play_freq(): data = request.json chord_index = data.get("chordIndex") node_index = data.get("nodeIndex") + octave = data.get("octave", 0) if chord_index < 0 or chord_index >= len(chords): return jsonify({"error": "Invalid chord index"}), 400 @@ -109,7 +110,7 @@ def play_freq(): pitch = chord[node_index] fraction = Fraction(pitch.get("fraction", "1")) - frequency = fundamental * float(fraction) + frequency = fundamental * float(fraction) * (2**octave) voice = node_index + 1 # 1-indexed osc_sender.send_single(frequency, voice)