Fix ghost node SuperCollider playback: send frequency directly, apply octave adjustment, fix server error
This commit is contained in:
parent
f77d680609
commit
1953c8b359
|
|
@ -1106,14 +1106,19 @@
|
|||
// 1. Shift+click → SuperCollider (FIRST)
|
||||
if (isShift) {
|
||||
const endpoint = '/api/play-freq';
|
||||
const octave = parseInt(document.getElementById('octaveInput').value) || 0;
|
||||
|
||||
const requestBody = {
|
||||
// If ghost node with its own frequency, send directly; otherwise use chordIndex/nodeIndex
|
||||
const requestBody = node.data('frequency') ? {
|
||||
frequency: node.data('frequency'),
|
||||
octave: octave,
|
||||
} : {
|
||||
chordIndex: chordIndex,
|
||||
nodeIndex: localId,
|
||||
octave: parseInt(document.getElementById('octaveInput').value) || 0,
|
||||
octave: octave,
|
||||
};
|
||||
|
||||
console.log('Sending to SuperCollider:', chordIndex, localId);
|
||||
console.log('Sending to SuperCollider:', node.data('frequency') ? 'direct frequency' : chordIndex + ',' + localId);
|
||||
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -111,7 +111,24 @@ def play_freq():
|
|||
chord_index = data.get("chordIndex")
|
||||
node_index = data.get("nodeIndex")
|
||||
octave = data.get("octave", 0)
|
||||
frequency_input = data.get("frequency") # direct frequency for ghost nodes
|
||||
|
||||
# If frequency provided directly (ghost node), use it
|
||||
if frequency_input is not None:
|
||||
frequency = float(frequency_input) * (2**octave)
|
||||
voice = 1 # Use voice 1 for ghost nodes
|
||||
osc_sender.send_single(frequency, voice)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"frequency": frequency,
|
||||
"voice": voice,
|
||||
"fundamental": fundamental,
|
||||
"fraction": "ghost",
|
||||
}
|
||||
)
|
||||
|
||||
# Original node: calculate from chordIndex/nodeIndex
|
||||
if chord_index < 0 or chord_index >= len(chords):
|
||||
return jsonify({"error": "Invalid chord index"}), 400
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue