Add octave offset for play-freq, adjustable via UI input
This commit is contained in:
parent
990e59b1d6
commit
2a17339edc
|
|
@ -281,6 +281,8 @@
|
|||
<button id="loadFileBtn">Load</button>
|
||||
<span style="margin-left: 20px;">Fundamental (Hz):</span>
|
||||
<input type="number" id="fundamentalInput" value="110" style="width: 60px;">
|
||||
<span style="margin-left: 15px;">Octave:</span>
|
||||
<input type="number" id="octaveInput" value="2" style="width: 40px;">
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue