Add audio node graph editing
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Three connected nodes -->
|
||||
|
||||
<!-- Node 1 (left) -->
|
||||
<rect x="2" y="8" width="6" height="8" rx="1" fill="#4d4d4d" stroke="#fff" stroke-width="1.5"/>
|
||||
|
||||
<!-- Node 2 (top right) -->
|
||||
<rect x="16" y="2" width="6" height="6" rx="1" fill="#4d4d4d" stroke="#fff" stroke-width="1.5"/>
|
||||
|
||||
<!-- Node 3 (bottom right) -->
|
||||
<rect x="16" y="16" width="6" height="6" rx="1" fill="#4d4d4d" stroke="#fff" stroke-width="1.5"/>
|
||||
|
||||
<!-- Connection lines -->
|
||||
<path d="M 8 10 L 16 5" stroke="#4CAF50" stroke-width="2" stroke-linecap="round"/>
|
||||
<path d="M 8 14 L 16 19" stroke="#2196F3" stroke-width="2" stroke-linecap="round"/>
|
||||
|
||||
<!-- Port dots -->
|
||||
<circle cx="8" cy="10" r="2" fill="#4CAF50"/>
|
||||
<circle cx="16" cy="5" r="2" fill="#4CAF50"/>
|
||||
<circle cx="8" cy="14" r="2" fill="#2196F3"/>
|
||||
<circle cx="16" cy="19" r="2" fill="#2196F3"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 939 B |
@@ -0,0 +1,217 @@
|
||||
:root {
|
||||
--dfBackgroundColor: rgba(47, 47, 47, 1);
|
||||
--dfBackgroundSize: 64px;
|
||||
--dfBackgroundImage: radial-gradient(rgba(77, 77, 77, 1) 1px, transparent 1px);
|
||||
|
||||
--dfNodeType: flex;
|
||||
--dfNodeTypeFloat: none;
|
||||
--dfNodeBackgroundColor: rgba(88, 88, 88, 1);
|
||||
--dfNodeTextColor: rgba(255, 255, 255, 1);
|
||||
--dfNodeBorderSize: 2px;
|
||||
--dfNodeBorderColor: rgba(99, 99, 99, 1);
|
||||
--dfNodeBorderRadius: 12px;
|
||||
--dfNodeMinHeight: 40px;
|
||||
--dfNodeMinWidth: 160px;
|
||||
--dfNodePaddingTop: 15px;
|
||||
--dfNodePaddingBottom: 15px;
|
||||
--dfNodeBoxShadowHL: 0px;
|
||||
--dfNodeBoxShadowVL: 2px;
|
||||
--dfNodeBoxShadowBR: 15px;
|
||||
--dfNodeBoxShadowS: 2px;
|
||||
--dfNodeBoxShadowColor: rgba(0, 0, 0, 0.37);
|
||||
|
||||
--dfNodeHoverBackgroundColor: rgba(115, 115, 115, 1);
|
||||
--dfNodeHoverTextColor: rgba(255, 255, 255, 1);
|
||||
--dfNodeHoverBorderSize: 2px;
|
||||
--dfNodeHoverBorderColor: rgba(135, 135, 135, 1);
|
||||
--dfNodeHoverBorderRadius: 12px;
|
||||
|
||||
--dfNodeHoverBoxShadowHL: 0px;
|
||||
--dfNodeHoverBoxShadowVL: 2px;
|
||||
--dfNodeHoverBoxShadowBR: 15px;
|
||||
--dfNodeHoverBoxShadowS: 2px;
|
||||
--dfNodeHoverBoxShadowColor: rgba(24, 24, 24, 1);
|
||||
|
||||
--dfNodeSelectedBackgroundColor: rgba(132, 132, 132, 1);
|
||||
--dfNodeSelectedTextColor: #ffffff;
|
||||
--dfNodeSelectedBorderSize: 2px;
|
||||
--dfNodeSelectedBorderColor: rgba(183, 183, 183, 1);
|
||||
--dfNodeSelectedBorderRadius: 12px;
|
||||
|
||||
--dfNodeSelectedBoxShadowHL: 0px;
|
||||
--dfNodeSelectedBoxShadowVL: 2px;
|
||||
--dfNodeSelectedBoxShadowBR: 15px;
|
||||
--dfNodeSelectedBoxShadowS: 2px;
|
||||
--dfNodeSelectedBoxShadowColor: rgba(0, 0, 0, 0.28);
|
||||
|
||||
--dfInputBackgroundColor: rgba(135, 135, 135, 1);
|
||||
--dfInputBorderSize: 2px;
|
||||
--dfInputBorderColor: #000000;
|
||||
--dfInputBorderRadius: 10px;
|
||||
--dfInputLeft: -27px;
|
||||
--dfInputHeight: 15px;
|
||||
--dfInputWidth: 15px;
|
||||
|
||||
--dfInputHoverBackgroundColor: #ffffff;
|
||||
--dfInputHoverBorderSize: 2px;
|
||||
--dfInputHoverBorderColor: #000000;
|
||||
--dfInputHoverBorderRadius: 50px;
|
||||
|
||||
--dfOutputBackgroundColor: rgba(147, 147, 147, 1);
|
||||
--dfOutputBorderSize: 2px;
|
||||
--dfOutputBorderColor: #000000;
|
||||
--dfOutputBorderRadius: 50px;
|
||||
--dfOutputRight: -3px;
|
||||
--dfOutputHeight: 15px;
|
||||
--dfOutputWidth: 15px;
|
||||
|
||||
--dfOutputHoverBackgroundColor: #ffffff;
|
||||
--dfOutputHoverBorderSize: 2px;
|
||||
--dfOutputHoverBorderColor: #000000;
|
||||
--dfOutputHoverBorderRadius: 50px;
|
||||
|
||||
--dfLineWidth: 5px;
|
||||
--dfLineColor: rgba(137, 137, 137, 1);
|
||||
--dfLineHoverColor: #4682b4;
|
||||
--dfLineSelectedColor: #43b993;
|
||||
|
||||
--dfRerouteBorderWidth: 2px;
|
||||
--dfRerouteBorderColor: #000000;
|
||||
--dfRerouteBackgroundColor: rgba(193, 193, 193, 1);
|
||||
|
||||
--dfRerouteHoverBorderWidth: 2px;
|
||||
--dfRerouteHoverBorderColor: #000000;
|
||||
--dfRerouteHoverBackgroundColor: #ffffff;
|
||||
|
||||
--dfDeleteDisplay: block;
|
||||
--dfDeleteColor: #ffffff;
|
||||
--dfDeleteBackgroundColor: #000000;
|
||||
--dfDeleteBorderSize: 2px;
|
||||
--dfDeleteBorderColor: #ffffff;
|
||||
--dfDeleteBorderRadius: 50px;
|
||||
--dfDeleteTop: -15px;
|
||||
|
||||
--dfDeleteHoverColor: #000000;
|
||||
--dfDeleteHoverBackgroundColor: #ffffff;
|
||||
--dfDeleteHoverBorderSize: 2px;
|
||||
--dfDeleteHoverBorderColor: #000000;
|
||||
--dfDeleteHoverBorderRadius: 50px;
|
||||
|
||||
}
|
||||
|
||||
#drawflow {
|
||||
background: var(--dfBackgroundColor);
|
||||
background-size: var(--dfBackgroundSize) var(--dfBackgroundSize);
|
||||
background-image: var(--dfBackgroundImage);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node {
|
||||
display: var(--dfNodeType);
|
||||
background: var(--dfNodeBackgroundColor);
|
||||
color: var(--dfNodeTextColor);
|
||||
border: var(--dfNodeBorderSize) solid var(--dfNodeBorderColor);
|
||||
border-radius: var(--dfNodeBorderRadius);
|
||||
min-height: var(--dfNodeMinHeight);
|
||||
width: auto;
|
||||
min-width: var(--dfNodeMinWidth);
|
||||
padding-top: var(--dfNodePaddingTop);
|
||||
padding-bottom: var(--dfNodePaddingBottom);
|
||||
-webkit-box-shadow: var(--dfNodeBoxShadowHL) var(--dfNodeBoxShadowVL) var(--dfNodeBoxShadowBR) var(--dfNodeBoxShadowS) var(--dfNodeBoxShadowColor);
|
||||
box-shadow: var(--dfNodeBoxShadowHL) var(--dfNodeBoxShadowVL) var(--dfNodeBoxShadowBR) var(--dfNodeBoxShadowS) var(--dfNodeBoxShadowColor);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node:hover {
|
||||
background: var(--dfNodeHoverBackgroundColor);
|
||||
color: var(--dfNodeHoverTextColor);
|
||||
border: var(--dfNodeHoverBorderSize) solid var(--dfNodeHoverBorderColor);
|
||||
border-radius: var(--dfNodeHoverBorderRadius);
|
||||
-webkit-box-shadow: var(--dfNodeHoverBoxShadowHL) var(--dfNodeHoverBoxShadowVL) var(--dfNodeHoverBoxShadowBR) var(--dfNodeHoverBoxShadowS) var(--dfNodeHoverBoxShadowColor);
|
||||
box-shadow: var(--dfNodeHoverBoxShadowHL) var(--dfNodeHoverBoxShadowVL) var(--dfNodeHoverBoxShadowBR) var(--dfNodeHoverBoxShadowS) var(--dfNodeHoverBoxShadowColor);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.selected {
|
||||
background: var(--dfNodeSelectedBackgroundColor);
|
||||
color: var(--dfNodeSelectedTextColor);
|
||||
border: var(--dfNodeSelectedBorderSize) solid var(--dfNodeSelectedBorderColor);
|
||||
border-radius: var(--dfNodeSelectedBorderRadius);
|
||||
-webkit-box-shadow: var(--dfNodeSelectedBoxShadowHL) var(--dfNodeSelectedBoxShadowVL) var(--dfNodeSelectedBoxShadowBR) var(--dfNodeSelectedBoxShadowS) var(--dfNodeSelectedBoxShadowColor);
|
||||
box-shadow: var(--dfNodeSelectedBoxShadowHL) var(--dfNodeSelectedBoxShadowVL) var(--dfNodeSelectedBoxShadowBR) var(--dfNodeSelectedBoxShadowS) var(--dfNodeSelectedBoxShadowColor);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node .input {
|
||||
left: var(--dfInputLeft);
|
||||
background: var(--dfInputBackgroundColor);
|
||||
border: var(--dfInputBorderSize) solid var(--dfInputBorderColor);
|
||||
border-radius: var(--dfInputBorderRadius);
|
||||
height: var(--dfInputHeight);
|
||||
width: var(--dfInputWidth);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node .input:hover {
|
||||
background: var(--dfInputHoverBackgroundColor);
|
||||
border: var(--dfInputHoverBorderSize) solid var(--dfInputHoverBorderColor);
|
||||
border-radius: var(--dfInputHoverBorderRadius);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node .outputs {
|
||||
float: var(--dfNodeTypeFloat);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node .output {
|
||||
right: var(--dfOutputRight);
|
||||
background: var(--dfOutputBackgroundColor);
|
||||
border: var(--dfOutputBorderSize) solid var(--dfOutputBorderColor);
|
||||
border-radius: var(--dfOutputBorderRadius);
|
||||
height: var(--dfOutputHeight);
|
||||
width: var(--dfOutputWidth);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node .output:hover {
|
||||
background: var(--dfOutputHoverBackgroundColor);
|
||||
border: var(--dfOutputHoverBorderSize) solid var(--dfOutputHoverBorderColor);
|
||||
border-radius: var(--dfOutputHoverBorderRadius);
|
||||
}
|
||||
|
||||
.drawflow .connection .main-path {
|
||||
stroke-width: var(--dfLineWidth);
|
||||
stroke: var(--dfLineColor);
|
||||
}
|
||||
|
||||
.drawflow .connection .main-path:hover {
|
||||
stroke: var(--dfLineHoverColor);
|
||||
}
|
||||
|
||||
.drawflow .connection .main-path.selected {
|
||||
stroke: var(--dfLineSelectedColor);
|
||||
}
|
||||
|
||||
.drawflow .connection .point {
|
||||
stroke: var(--dfRerouteBorderColor);
|
||||
stroke-width: var(--dfRerouteBorderWidth);
|
||||
fill: var(--dfRerouteBackgroundColor);
|
||||
}
|
||||
|
||||
.drawflow .connection .point:hover {
|
||||
stroke: var(--dfRerouteHoverBorderColor);
|
||||
stroke-width: var(--dfRerouteHoverBorderWidth);
|
||||
fill: var(--dfRerouteHoverBackgroundColor);
|
||||
}
|
||||
|
||||
.drawflow-delete {
|
||||
display: var(--dfDeleteDisplay);
|
||||
color: var(--dfDeleteColor);
|
||||
background: var(--dfDeleteBackgroundColor);
|
||||
border: var(--dfDeleteBorderSize) solid var(--dfDeleteBorderColor);
|
||||
border-radius: var(--dfDeleteBorderRadius);
|
||||
}
|
||||
|
||||
.parent-node .drawflow-delete {
|
||||
top: var(--dfDeleteTop);
|
||||
}
|
||||
|
||||
.drawflow-delete:hover {
|
||||
color: var(--dfDeleteHoverColor);
|
||||
background: var(--dfDeleteHoverBackgroundColor);
|
||||
border: var(--dfDeleteHoverBorderSize) solid var(--dfDeleteHoverBorderColor);
|
||||
border-radius: var(--dfDeleteHoverBorderRadius);
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
.drawflow,.drawflow .parent-node{position:relative}.parent-drawflow{display:flex;overflow:hidden;touch-action:none;outline:0}.drawflow{width:100%;height:100%;user-select:none;perspective:0}.drawflow .drawflow-node{display:flex;align-items:center;position:absolute;background:#0ff;width:160px;min-height:40px;border-radius:4px;border:2px solid #000;color:#000;z-index:2;padding:15px}.drawflow .drawflow-node.selected{background:red}.drawflow .drawflow-node:hover{cursor:move}.drawflow .drawflow-node .inputs,.drawflow .drawflow-node .outputs{width:0}.drawflow .drawflow-node .drawflow_content_node{width:100%;display:block}.drawflow .drawflow-node .input,.drawflow .drawflow-node .output{position:relative;width:20px;height:20px;background:#fff;border-radius:50%;border:2px solid #000;cursor:crosshair;z-index:1;margin-bottom:5px}.drawflow .drawflow-node .input{left:-27px;top:2px;background:#ff0}.drawflow .drawflow-node .output{right:-3px;top:2px}.drawflow svg{z-index:0;position:absolute;overflow:visible!important}.drawflow .connection{position:absolute;pointer-events:none;aspect-ratio:1/1}.drawflow .connection .main-path{fill:none;stroke-width:5px;stroke:#4682b4;pointer-events:all}.drawflow .connection .main-path:hover{stroke:#1266ab;cursor:pointer}.drawflow .connection .main-path.selected{stroke:#43b993}.drawflow .connection .point{cursor:move;stroke:#000;stroke-width:2;fill:#fff;pointer-events:all}.drawflow .connection .point.selected,.drawflow .connection .point:hover{fill:#1266ab}.drawflow .main-path{fill:none;stroke-width:5px;stroke:#4682b4}.drawflow-delete{position:absolute;display:block;width:30px;height:30px;background:#000;color:#fff;z-index:4;border:2px solid #fff;line-height:30px;font-weight:700;text-align:center;border-radius:50%;font-family:monospace;cursor:pointer}.drawflow>.drawflow-delete{margin-left:-15px;margin-top:15px}.parent-node .drawflow-delete{right:-15px;top:-15px}
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -25,6 +25,11 @@
|
||||
<script src="UPNG.js"></script>
|
||||
<script src="pako.js"></script>
|
||||
<script type="module" src="/d3-interpolate-path.js"></script>
|
||||
|
||||
<!-- Drawflow for node-based editor -->
|
||||
<link rel="stylesheet" href="/drawflow.min.css">
|
||||
<script src="/drawflow.min.js"></script>
|
||||
|
||||
<script type="module" src="/main.js" defer></script>
|
||||
</head>
|
||||
|
||||
|
||||
+2
-2
@@ -79,10 +79,10 @@ export const defaultLayouts = {
|
||||
children: [
|
||||
{
|
||||
type: "vertical-grid",
|
||||
percent: 70,
|
||||
percent: 50,
|
||||
children: [
|
||||
{ type: "pane", name: "timelineV2" },
|
||||
{ type: "pane", name: "piano"}
|
||||
{ type: "pane", name: "nodeEditor"}
|
||||
]
|
||||
},
|
||||
{ type: "pane", name: "infopanel" }
|
||||
|
||||
+685
@@ -62,6 +62,7 @@ import {
|
||||
} from "./styles.js";
|
||||
import { Icon } from "./icon.js";
|
||||
import { AlphaSelectionBar, ColorSelectorWidget, ColorWidget, HueSelectionBar, SaturationValueSelectionGradient, TimelineWindow, TimelineWindowV2, VirtualPiano, PianoRollEditor, Widget } from "./widgets.js";
|
||||
import { nodeTypes, SignalType, getPortClass } from "./nodeTypes.js";
|
||||
|
||||
// State management
|
||||
import {
|
||||
@@ -6041,6 +6042,686 @@ async function renderMenu() {
|
||||
}
|
||||
updateMenu();
|
||||
|
||||
function nodeEditor() {
|
||||
// Create container for the node editor
|
||||
const container = document.createElement("div");
|
||||
container.id = "node-editor-container";
|
||||
|
||||
// Create the Drawflow canvas
|
||||
const editorDiv = document.createElement("div");
|
||||
editorDiv.id = "drawflow";
|
||||
editorDiv.style.width = "100%";
|
||||
editorDiv.style.height = "100%";
|
||||
editorDiv.style.position = "relative";
|
||||
container.appendChild(editorDiv);
|
||||
|
||||
// Create node palette
|
||||
const palette = document.createElement("div");
|
||||
palette.className = "node-palette";
|
||||
palette.innerHTML = `
|
||||
<h3>Nodes</h3>
|
||||
${Object.entries(nodeTypes)
|
||||
.filter(([type, def]) => type !== 'TemplateInput' && type !== 'TemplateOutput') // Hide template nodes
|
||||
.map(([type, def]) => `
|
||||
<div class="node-palette-item" data-node-type="${type}">
|
||||
${def.name}
|
||||
</div>
|
||||
`).join('')}
|
||||
`;
|
||||
container.appendChild(palette);
|
||||
|
||||
// Initialize Drawflow editor (will be set up after DOM insertion)
|
||||
let editor = null;
|
||||
let nodeIdCounter = 1;
|
||||
|
||||
// Track expanded VoiceAllocator nodes
|
||||
const expandedNodes = new Set(); // Set of node IDs that are expanded
|
||||
const nodeParents = new Map(); // Map of child node ID -> parent VoiceAllocator ID
|
||||
|
||||
// Wait for DOM insertion
|
||||
setTimeout(() => {
|
||||
const drawflowDiv = container.querySelector("#drawflow");
|
||||
if (!drawflowDiv) return;
|
||||
|
||||
editor = new Drawflow(drawflowDiv);
|
||||
editor.reroute = true;
|
||||
editor.reroute_fix_curvature = true;
|
||||
editor.force_first_input = false;
|
||||
editor.start();
|
||||
|
||||
// Store editor reference in context
|
||||
context.nodeEditor = editor;
|
||||
|
||||
// Add palette item drag-and-drop handlers
|
||||
const paletteItems = container.querySelectorAll(".node-palette-item");
|
||||
let draggedNodeType = null;
|
||||
|
||||
paletteItems.forEach(item => {
|
||||
// Make items draggable
|
||||
item.setAttribute('draggable', 'true');
|
||||
|
||||
// Click handler for quick add
|
||||
item.addEventListener("click", () => {
|
||||
const nodeType = item.getAttribute("data-node-type");
|
||||
addNode(nodeType, 100, 100, null);
|
||||
});
|
||||
|
||||
// Drag start
|
||||
item.addEventListener('dragstart', (e) => {
|
||||
draggedNodeType = item.getAttribute('data-node-type');
|
||||
e.dataTransfer.effectAllowed = 'copy';
|
||||
e.dataTransfer.setData('text/plain', draggedNodeType); // Required for drag to work
|
||||
console.log('Drag started:', draggedNodeType);
|
||||
});
|
||||
|
||||
// Drag end
|
||||
item.addEventListener('dragend', () => {
|
||||
console.log('Drag ended');
|
||||
draggedNodeType = null;
|
||||
});
|
||||
});
|
||||
|
||||
// Add drop handler to drawflow canvas
|
||||
drawflowDiv.addEventListener('dragover', (e) => {
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = 'copy';
|
||||
});
|
||||
|
||||
drawflowDiv.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// Get node type from dataTransfer instead of global variable
|
||||
const nodeType = e.dataTransfer.getData('text/plain');
|
||||
console.log('Drop event fired, nodeType:', nodeType);
|
||||
|
||||
if (!nodeType) {
|
||||
console.log('No nodeType in drop data, aborting');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get drop position relative to the editor
|
||||
const rect = drawflowDiv.getBoundingClientRect();
|
||||
const precanvasX = editor.precanvas?.x || 0;
|
||||
const precanvasY = editor.precanvas?.y || 0;
|
||||
const zoom = editor.zoom || 1;
|
||||
const x = (e.clientX - rect.left - precanvasX) / zoom;
|
||||
const y = (e.clientY - rect.top - precanvasY) / zoom;
|
||||
|
||||
console.log('Position calculation:', { clientX: e.clientX, clientY: e.clientY, rectLeft: rect.left, rectTop: rect.top, precanvasX, precanvasY, zoom, x, y });
|
||||
|
||||
// Check if dropping into an expanded VoiceAllocator
|
||||
let parentNodeId = null;
|
||||
for (const expandedNodeId of expandedNodes) {
|
||||
const contentsArea = document.getElementById(`voice-allocator-contents-${expandedNodeId}`);
|
||||
if (contentsArea) {
|
||||
const contentsRect = contentsArea.getBoundingClientRect();
|
||||
if (e.clientX >= contentsRect.left && e.clientX <= contentsRect.right &&
|
||||
e.clientY >= contentsRect.top && e.clientY <= contentsRect.bottom) {
|
||||
parentNodeId = expandedNodeId;
|
||||
console.log(`Dropping into VoiceAllocator ${expandedNodeId} at position (${x}, ${y})`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the node
|
||||
console.log(`Adding node ${nodeType} at (${x}, ${y}) with parent ${parentNodeId}`);
|
||||
addNode(nodeType, x, y, parentNodeId);
|
||||
|
||||
// Clear the draggedNodeType
|
||||
draggedNodeType = null;
|
||||
});
|
||||
|
||||
// Connection event handlers
|
||||
editor.on("connectionCreated", (connection) => {
|
||||
handleConnectionCreated(connection);
|
||||
});
|
||||
|
||||
editor.on("connectionRemoved", (connection) => {
|
||||
handleConnectionRemoved(connection);
|
||||
});
|
||||
|
||||
// Node events
|
||||
editor.on("nodeCreated", (nodeId) => {
|
||||
setupNodeParameters(nodeId);
|
||||
|
||||
// Add double-click handler for VoiceAllocator expansion
|
||||
setTimeout(() => {
|
||||
const nodeElement = document.getElementById(`node-${nodeId}`);
|
||||
if (nodeElement) {
|
||||
nodeElement.addEventListener('dblclick', (e) => {
|
||||
// Prevent double-click from bubbling to canvas
|
||||
e.stopPropagation();
|
||||
handleNodeDoubleClick(nodeId);
|
||||
});
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
|
||||
// Node moved - resize parent VoiceAllocator
|
||||
editor.on("nodeMoved", (nodeId) => {
|
||||
const node = editor.getNodeFromId(nodeId);
|
||||
if (node && node.data.parentNodeId) {
|
||||
resizeVoiceAllocatorToFit(node.data.parentNodeId);
|
||||
}
|
||||
});
|
||||
|
||||
// Node removed - prevent deletion of template nodes
|
||||
editor.on("nodeRemoved", (nodeId) => {
|
||||
const nodeElement = document.getElementById(`node-${nodeId}`);
|
||||
if (nodeElement && nodeElement.getAttribute('data-template-node') === 'true') {
|
||||
console.warn('Cannot delete template nodes');
|
||||
// TODO: Re-add the node if it was deleted
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up parent-child tracking
|
||||
const parentId = nodeParents.get(nodeId);
|
||||
nodeParents.delete(nodeId);
|
||||
|
||||
// Resize parent if needed
|
||||
if (parentId) {
|
||||
resizeVoiceAllocatorToFit(parentId);
|
||||
}
|
||||
});
|
||||
|
||||
}, 100);
|
||||
|
||||
// Add a node to the graph
|
||||
function addNode(nodeType, x, y, parentNodeId = null) {
|
||||
if (!editor) return;
|
||||
|
||||
const nodeDef = nodeTypes[nodeType];
|
||||
if (!nodeDef) return;
|
||||
|
||||
const nodeId = nodeIdCounter++;
|
||||
const html = nodeDef.getHTML(nodeId);
|
||||
|
||||
// Count inputs and outputs by type
|
||||
const inputsCount = nodeDef.inputs.length;
|
||||
const outputsCount = nodeDef.outputs.length;
|
||||
|
||||
// Add node to Drawflow
|
||||
const drawflowNodeId = editor.addNode(
|
||||
nodeType,
|
||||
inputsCount,
|
||||
outputsCount,
|
||||
x,
|
||||
y,
|
||||
`node-${nodeType.toLowerCase()}`,
|
||||
{ nodeType, backendId: null, parentNodeId: parentNodeId },
|
||||
html
|
||||
);
|
||||
|
||||
// Track parent-child relationship
|
||||
if (parentNodeId !== null) {
|
||||
nodeParents.set(drawflowNodeId, parentNodeId);
|
||||
console.log(`Node ${drawflowNodeId} (${nodeType}) is child of VoiceAllocator ${parentNodeId}`);
|
||||
|
||||
// Mark template nodes as non-deletable
|
||||
const isTemplateNode = (nodeType === 'TemplateInput' || nodeType === 'TemplateOutput');
|
||||
|
||||
// Add CSS class to mark as child node
|
||||
setTimeout(() => {
|
||||
const nodeElement = document.getElementById(`node-${drawflowNodeId}`);
|
||||
if (nodeElement) {
|
||||
nodeElement.classList.add('child-node');
|
||||
nodeElement.setAttribute('data-parent-node', parentNodeId);
|
||||
|
||||
if (isTemplateNode) {
|
||||
nodeElement.classList.add('template-node');
|
||||
nodeElement.setAttribute('data-template-node', 'true');
|
||||
}
|
||||
|
||||
// Only show if parent is currently expanded
|
||||
if (!expandedNodes.has(parentNodeId)) {
|
||||
nodeElement.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-resize parent VoiceAllocator after adding child node
|
||||
resizeVoiceAllocatorToFit(parentNodeId);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Apply port styling based on signal types
|
||||
setTimeout(() => {
|
||||
styleNodePorts(drawflowNodeId, nodeDef);
|
||||
}, 10);
|
||||
|
||||
// Send command to backend
|
||||
// If parent node exists, add to VoiceAllocator template; otherwise add to main graph
|
||||
const commandName = parentNodeId ? "graph_add_node_to_template" : "graph_add_node";
|
||||
const commandArgs = parentNodeId
|
||||
? {
|
||||
trackId: 0,
|
||||
voiceAllocatorId: editor.getNodeFromId(parentNodeId).data.backendId,
|
||||
nodeType: nodeType,
|
||||
x: x,
|
||||
y: y
|
||||
}
|
||||
: {
|
||||
trackId: 0,
|
||||
nodeType: nodeType,
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
|
||||
invoke(commandName, commandArgs).then(backendNodeId => {
|
||||
console.log(`Node ${nodeType} added with backend ID: ${backendNodeId} (parent: ${parentNodeId})`);
|
||||
|
||||
// Store backend node ID using Drawflow's update method
|
||||
editor.updateNodeDataFromId(drawflowNodeId, { nodeType, backendId: backendNodeId, parentNodeId: parentNodeId });
|
||||
|
||||
console.log("Verifying stored backend ID:", editor.getNodeFromId(drawflowNodeId).data.backendId);
|
||||
|
||||
// If this is an AudioOutput node, automatically set it as the graph output
|
||||
if (nodeType === "AudioOutput") {
|
||||
console.log(`Setting node ${backendNodeId} as graph output`);
|
||||
invoke("graph_set_output_node", {
|
||||
trackId: 0,
|
||||
nodeId: backendNodeId
|
||||
}).then(() => {
|
||||
console.log("Output node set successfully");
|
||||
}).catch(err => {
|
||||
console.error("Failed to set output node:", err);
|
||||
});
|
||||
}
|
||||
|
||||
// If this is a VoiceAllocator, automatically create template I/O nodes inside it
|
||||
if (nodeType === "VoiceAllocator") {
|
||||
setTimeout(() => {
|
||||
// Get the node position
|
||||
const node = editor.getNodeFromId(drawflowNodeId);
|
||||
if (node) {
|
||||
// Create TemplateInput on the left
|
||||
addNode("TemplateInput", node.pos_x + 50, node.pos_y + 100, drawflowNodeId);
|
||||
// Create TemplateOutput on the right
|
||||
addNode("TemplateOutput", node.pos_x + 450, node.pos_y + 100, drawflowNodeId);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error("Failed to add node to backend:", err);
|
||||
showError("Failed to add node: " + err);
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-resize VoiceAllocator to fit its child nodes
|
||||
function resizeVoiceAllocatorToFit(voiceAllocatorNodeId) {
|
||||
if (!voiceAllocatorNodeId) return;
|
||||
|
||||
const parentNode = editor.getNodeFromId(voiceAllocatorNodeId);
|
||||
const parentElement = document.getElementById(`node-${voiceAllocatorNodeId}`);
|
||||
if (!parentNode || !parentElement) return;
|
||||
|
||||
// Find all child nodes
|
||||
const childNodeIds = [];
|
||||
for (const [childId, parentId] of nodeParents.entries()) {
|
||||
if (parentId === voiceAllocatorNodeId) {
|
||||
childNodeIds.push(childId);
|
||||
}
|
||||
}
|
||||
|
||||
if (childNodeIds.length === 0) return;
|
||||
|
||||
// Calculate bounding box of all child nodes
|
||||
let minX = Infinity, minY = Infinity;
|
||||
let maxX = -Infinity, maxY = -Infinity;
|
||||
|
||||
for (const childId of childNodeIds) {
|
||||
const childNode = editor.getNodeFromId(childId);
|
||||
const childElement = document.getElementById(`node-${childId}`);
|
||||
if (!childNode || !childElement) continue;
|
||||
|
||||
const childWidth = childElement.offsetWidth || 200;
|
||||
const childHeight = childElement.offsetHeight || 150;
|
||||
|
||||
minX = Math.min(minX, childNode.pos_x);
|
||||
minY = Math.min(minY, childNode.pos_y);
|
||||
maxX = Math.max(maxX, childNode.pos_x + childWidth);
|
||||
maxY = Math.max(maxY, childNode.pos_y + childHeight);
|
||||
}
|
||||
|
||||
// Add generous margin
|
||||
const margin = 60;
|
||||
const headerHeight = 120; // Space for VoiceAllocator header
|
||||
|
||||
const requiredWidth = (maxX - minX) + (margin * 2);
|
||||
const requiredHeight = (maxY - minY) + (margin * 2) + headerHeight;
|
||||
|
||||
// Set minimum size
|
||||
const finalWidth = Math.max(requiredWidth, 600);
|
||||
const finalHeight = Math.max(requiredHeight, 400);
|
||||
|
||||
// Only resize if expanded
|
||||
if (expandedNodes.has(voiceAllocatorNodeId)) {
|
||||
parentElement.style.width = `${finalWidth}px`;
|
||||
parentElement.style.height = `${finalHeight}px`;
|
||||
parentElement.style.minWidth = `${finalWidth}px`;
|
||||
parentElement.style.minHeight = `${finalHeight}px`;
|
||||
|
||||
console.log(`Resized VoiceAllocator ${voiceAllocatorNodeId} to ${finalWidth}x${finalHeight}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Style node ports based on signal types
|
||||
function styleNodePorts(nodeId, nodeDef) {
|
||||
const nodeElement = document.getElementById(`node-${nodeId}`);
|
||||
if (!nodeElement) return;
|
||||
|
||||
// Style input ports
|
||||
const inputs = nodeElement.querySelectorAll(".input");
|
||||
inputs.forEach((input, index) => {
|
||||
if (index < nodeDef.inputs.length) {
|
||||
const portDef = nodeDef.inputs[index];
|
||||
const connector = input.querySelector(".input_0, .input_1, .input_2, .input_3");
|
||||
if (connector) {
|
||||
connector.classList.add(getPortClass(portDef.type));
|
||||
}
|
||||
// Add label
|
||||
const label = document.createElement("span");
|
||||
label.textContent = portDef.name;
|
||||
input.insertBefore(label, input.firstChild);
|
||||
}
|
||||
});
|
||||
|
||||
// Style output ports
|
||||
const outputs = nodeElement.querySelectorAll(".output");
|
||||
outputs.forEach((output, index) => {
|
||||
if (index < nodeDef.outputs.length) {
|
||||
const portDef = nodeDef.outputs[index];
|
||||
const connector = output.querySelector(".output_0, .output_1, .output_2, .output_3");
|
||||
if (connector) {
|
||||
connector.classList.add(getPortClass(portDef.type));
|
||||
}
|
||||
// Add label
|
||||
const label = document.createElement("span");
|
||||
label.textContent = portDef.name;
|
||||
output.appendChild(label);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Setup parameter event listeners for a node
|
||||
function setupNodeParameters(nodeId) {
|
||||
setTimeout(() => {
|
||||
const nodeElement = document.getElementById(`node-${nodeId}`);
|
||||
if (!nodeElement) return;
|
||||
|
||||
const sliders = nodeElement.querySelectorAll(".node-slider");
|
||||
sliders.forEach(slider => {
|
||||
// Prevent node dragging when interacting with slider
|
||||
slider.addEventListener("mousedown", (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
slider.addEventListener("pointerdown", (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
slider.addEventListener("input", (e) => {
|
||||
const paramId = parseInt(e.target.getAttribute("data-param"));
|
||||
const value = parseFloat(e.target.value);
|
||||
|
||||
// Update display
|
||||
const nodeData = editor.getNodeFromId(nodeId);
|
||||
if (nodeData) {
|
||||
const nodeDef = nodeTypes[nodeData.name];
|
||||
if (nodeDef && nodeDef.parameters[paramId]) {
|
||||
const param = nodeDef.parameters[paramId];
|
||||
const displaySpan = nodeElement.querySelector(`#${param.name}-${nodeId}`);
|
||||
if (displaySpan) {
|
||||
displaySpan.textContent = value.toFixed(param.unit === 'Hz' ? 0 : 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Send to backend
|
||||
if (nodeData.data.backendId !== null) {
|
||||
invoke("graph_set_parameter", {
|
||||
trackId: 0,
|
||||
nodeId: nodeData.data.backendId,
|
||||
paramId: paramId,
|
||||
value: value
|
||||
}).catch(err => {
|
||||
console.error("Failed to set parameter:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// Handle double-click on nodes (for VoiceAllocator expansion)
|
||||
function handleNodeDoubleClick(nodeId) {
|
||||
const node = editor.getNodeFromId(nodeId);
|
||||
if (!node) return;
|
||||
|
||||
// Only VoiceAllocator nodes can be expanded
|
||||
if (node.data.nodeType !== 'VoiceAllocator') return;
|
||||
|
||||
const nodeElement = document.getElementById(`node-${nodeId}`);
|
||||
if (!nodeElement) return;
|
||||
|
||||
const contentsArea = document.getElementById(`voice-allocator-contents-${nodeId}`);
|
||||
if (!contentsArea) return;
|
||||
|
||||
// Toggle expanded state
|
||||
if (expandedNodes.has(nodeId)) {
|
||||
// Collapse
|
||||
expandedNodes.delete(nodeId);
|
||||
nodeElement.classList.remove('expanded');
|
||||
nodeElement.style.width = '';
|
||||
nodeElement.style.height = '';
|
||||
nodeElement.style.minWidth = '';
|
||||
nodeElement.style.minHeight = '';
|
||||
contentsArea.style.display = 'none';
|
||||
|
||||
// Hide all child nodes
|
||||
for (const [childId, parentId] of nodeParents.entries()) {
|
||||
if (parentId === nodeId) {
|
||||
const childElement = document.getElementById(`node-${childId}`);
|
||||
if (childElement) {
|
||||
childElement.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Collapsed VoiceAllocator node:', nodeId);
|
||||
} else {
|
||||
// Expand
|
||||
expandedNodes.add(nodeId);
|
||||
nodeElement.classList.add('expanded');
|
||||
|
||||
// Make the node larger to show contents
|
||||
nodeElement.style.width = '600px';
|
||||
nodeElement.style.height = '400px';
|
||||
nodeElement.style.minWidth = '600px';
|
||||
nodeElement.style.minHeight = '400px';
|
||||
contentsArea.style.display = 'block';
|
||||
|
||||
// Show all child nodes
|
||||
for (const [childId, parentId] of nodeParents.entries()) {
|
||||
if (parentId === nodeId) {
|
||||
const childElement = document.getElementById(`node-${childId}`);
|
||||
if (childElement) {
|
||||
childElement.style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Expanded VoiceAllocator node:', nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle connection creation
|
||||
function handleConnectionCreated(connection) {
|
||||
console.log("handleConnectionCreated called:", connection);
|
||||
const outputNode = editor.getNodeFromId(connection.output_id);
|
||||
const inputNode = editor.getNodeFromId(connection.input_id);
|
||||
|
||||
console.log("Output node:", outputNode, "Input node:", inputNode);
|
||||
if (!outputNode || !inputNode) {
|
||||
console.log("Missing node - returning");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Output node name:", outputNode.name, "Input node name:", inputNode.name);
|
||||
const outputDef = nodeTypes[outputNode.name];
|
||||
const inputDef = nodeTypes[inputNode.name];
|
||||
|
||||
console.log("Output def:", outputDef, "Input def:", inputDef);
|
||||
if (!outputDef || !inputDef) {
|
||||
console.log("Missing node definition - returning");
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract port indices from connection class names
|
||||
// Drawflow uses 1-based indexing, but our arrays are 0-based
|
||||
const outputPort = parseInt(connection.output_class.replace("output_", "")) - 1;
|
||||
const inputPort = parseInt(connection.input_class.replace("input_", "")) - 1;
|
||||
|
||||
console.log("Port indices (0-based) - output:", outputPort, "input:", inputPort);
|
||||
console.log("Output class:", connection.output_class, "Input class:", connection.input_class);
|
||||
|
||||
// Validate signal types
|
||||
console.log("Checking port bounds - outputPort:", outputPort, "< outputs.length:", outputDef.outputs.length, "inputPort:", inputPort, "< inputs.length:", inputDef.inputs.length);
|
||||
if (outputPort < outputDef.outputs.length && inputPort < inputDef.inputs.length) {
|
||||
const outputType = outputDef.outputs[outputPort].type;
|
||||
const inputType = inputDef.inputs[inputPort].type;
|
||||
|
||||
console.log("Signal types - output:", outputType, "input:", inputType);
|
||||
|
||||
if (outputType !== inputType) {
|
||||
console.log("TYPE MISMATCH! Removing connection");
|
||||
// Type mismatch - remove connection
|
||||
editor.removeSingleConnection(
|
||||
connection.output_id,
|
||||
connection.input_id,
|
||||
connection.output_class,
|
||||
connection.input_class
|
||||
);
|
||||
showError(`Cannot connect ${outputType} to ${inputType}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Types match - proceeding with connection");
|
||||
|
||||
// Style the connection based on signal type
|
||||
setTimeout(() => {
|
||||
const connectionElement = document.querySelector(
|
||||
`.connection.node_in_node-${connection.input_id}.node_out_node-${connection.output_id}`
|
||||
);
|
||||
if (connectionElement) {
|
||||
connectionElement.classList.add(`connection-${outputType}`);
|
||||
}
|
||||
}, 10);
|
||||
|
||||
// Send to backend
|
||||
console.log("Backend IDs - output:", outputNode.data.backendId, "input:", inputNode.data.backendId);
|
||||
if (outputNode.data.backendId !== null && inputNode.data.backendId !== null) {
|
||||
// Check if both nodes are inside the same VoiceAllocator
|
||||
// Convert connection IDs to numbers to match Map keys
|
||||
const outputId = parseInt(connection.output_id);
|
||||
const inputId = parseInt(connection.input_id);
|
||||
const outputParent = nodeParents.get(outputId);
|
||||
const inputParent = nodeParents.get(inputId);
|
||||
console.log(`Parent detection - output node ${outputId} parent: ${outputParent}, input node ${inputId} parent: ${inputParent}`);
|
||||
|
||||
if (outputParent && inputParent && outputParent === inputParent) {
|
||||
// Both nodes are inside the same VoiceAllocator - connect in template
|
||||
const parentNode = editor.getNodeFromId(outputParent);
|
||||
console.log(`Connecting in VoiceAllocator template ${parentNode.data.backendId}: node ${outputNode.data.backendId} port ${outputPort} -> node ${inputNode.data.backendId} port ${inputPort}`);
|
||||
invoke("graph_connect_in_template", {
|
||||
trackId: 0,
|
||||
voiceAllocatorId: parentNode.data.backendId,
|
||||
fromNode: outputNode.data.backendId,
|
||||
fromPort: outputPort,
|
||||
toNode: inputNode.data.backendId,
|
||||
toPort: inputPort
|
||||
}).then(() => {
|
||||
console.log("Template connection successful");
|
||||
}).catch(err => {
|
||||
console.error("Failed to connect nodes in template:", err);
|
||||
showError("Template connection failed: " + err);
|
||||
// Remove the connection
|
||||
editor.removeSingleConnection(
|
||||
connection.output_id,
|
||||
connection.input_id,
|
||||
connection.output_class,
|
||||
connection.input_class
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// Normal connection in main graph
|
||||
console.log(`Connecting: node ${outputNode.data.backendId} port ${outputPort} -> node ${inputNode.data.backendId} port ${inputPort}`);
|
||||
invoke("graph_connect", {
|
||||
trackId: 0,
|
||||
fromNode: outputNode.data.backendId,
|
||||
fromPort: outputPort,
|
||||
toNode: inputNode.data.backendId,
|
||||
toPort: inputPort
|
||||
}).then(() => {
|
||||
console.log("Connection successful");
|
||||
}).catch(err => {
|
||||
console.error("Failed to connect nodes:", err);
|
||||
showError("Connection failed: " + err);
|
||||
// Remove the connection
|
||||
editor.removeSingleConnection(
|
||||
connection.output_id,
|
||||
connection.input_id,
|
||||
connection.output_class,
|
||||
connection.input_class
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Port validation FAILED - ports out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
// Handle connection removal
|
||||
function handleConnectionRemoved(connection) {
|
||||
const outputNode = editor.getNodeFromId(connection.output_id);
|
||||
const inputNode = editor.getNodeFromId(connection.input_id);
|
||||
|
||||
if (!outputNode || !inputNode) return;
|
||||
|
||||
// Drawflow uses 1-based indexing, but our arrays are 0-based
|
||||
const outputPort = parseInt(connection.output_class.replace("output_", "")) - 1;
|
||||
const inputPort = parseInt(connection.input_class.replace("input_", "")) - 1;
|
||||
|
||||
// Send to backend
|
||||
if (outputNode.data.backendId !== null && inputNode.data.backendId !== null) {
|
||||
invoke("graph_disconnect", {
|
||||
trackId: 0,
|
||||
fromNode: outputNode.data.backendId,
|
||||
fromPort: outputPort,
|
||||
toNode: inputNode.data.backendId,
|
||||
toPort: inputPort
|
||||
}).catch(err => {
|
||||
console.error("Failed to disconnect nodes:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Show error message
|
||||
function showError(message) {
|
||||
const errorDiv = document.createElement("div");
|
||||
errorDiv.className = "node-editor-error";
|
||||
errorDiv.textContent = message;
|
||||
container.appendChild(errorDiv);
|
||||
|
||||
setTimeout(() => {
|
||||
errorDiv.remove();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function piano() {
|
||||
let piano_cvs = document.createElement("canvas");
|
||||
piano_cvs.className = "piano";
|
||||
@@ -6234,6 +6915,10 @@ const panes = {
|
||||
name: "piano-roll",
|
||||
func: pianoRoll,
|
||||
},
|
||||
nodeEditor: {
|
||||
name: "node-editor",
|
||||
func: nodeEditor,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,444 @@
|
||||
// Node type definitions for the audio node graph editor
|
||||
// Each node type defines its inputs, outputs, parameters, and HTML template
|
||||
|
||||
/**
|
||||
* Signal types for node ports
|
||||
* These match the backend SignalType enum
|
||||
*/
|
||||
export const SignalType = {
|
||||
AUDIO: 'audio', // Blue circles
|
||||
MIDI: 'midi', // Green squares
|
||||
CV: 'cv' // Orange diamonds
|
||||
};
|
||||
|
||||
/**
|
||||
* Node category for organization in the palette
|
||||
*/
|
||||
export const NodeCategory = {
|
||||
INPUT: 'input',
|
||||
GENERATOR: 'generator',
|
||||
EFFECT: 'effect',
|
||||
UTILITY: 'utility',
|
||||
OUTPUT: 'output'
|
||||
};
|
||||
|
||||
/**
|
||||
* Get CSS class for a port based on its signal type
|
||||
*/
|
||||
export function getPortClass(signalType) {
|
||||
return `connector-${signalType}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Node type catalog
|
||||
* Maps node type names to their definitions
|
||||
*/
|
||||
export const nodeTypes = {
|
||||
Oscillator: {
|
||||
name: 'Oscillator',
|
||||
category: NodeCategory.GENERATOR,
|
||||
description: 'Oscillator with multiple waveforms and CV modulation',
|
||||
inputs: [
|
||||
{ name: 'V/Oct', type: SignalType.CV, index: 0 },
|
||||
{ name: 'FM', type: SignalType.CV, index: 1 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Audio', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'frequency', label: 'Frequency', min: 20, max: 20000, default: 440, unit: 'Hz' },
|
||||
{ id: 1, name: 'amplitude', label: 'Amplitude', min: 0, max: 1, default: 0.5, unit: '' },
|
||||
{ id: 2, name: 'waveform', label: 'Waveform', min: 0, max: 3, default: 0, unit: '' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Oscillator</div>
|
||||
<div class="node-param">
|
||||
<label>Waveform: <span id="wave-${nodeId}">Sine</span></label>
|
||||
<input type="range"
|
||||
class="node-slider"
|
||||
data-node="${nodeId}"
|
||||
data-param="2"
|
||||
min="0"
|
||||
max="3"
|
||||
value="0"
|
||||
step="1">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Frequency: <span id="freq-${nodeId}">440</span> Hz</label>
|
||||
<input type="range"
|
||||
class="node-slider"
|
||||
data-node="${nodeId}"
|
||||
data-param="0"
|
||||
min="20"
|
||||
max="20000"
|
||||
value="440"
|
||||
step="1">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Amplitude: <span id="amp-${nodeId}">0.5</span></label>
|
||||
<input type="range"
|
||||
class="node-slider"
|
||||
data-node="${nodeId}"
|
||||
data-param="1"
|
||||
min="0"
|
||||
max="1"
|
||||
value="0.5"
|
||||
step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
Gain: {
|
||||
name: 'Gain',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'VCA (voltage-controlled amplifier) - CV multiplies gain',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 },
|
||||
{ name: 'CV', type: SignalType.CV, index: 1 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'gain', label: 'Gain', min: 0, max: 2, default: 1, unit: 'x' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Gain</div>
|
||||
<div class="node-param">
|
||||
<label>Gain: <span id="gain-${nodeId}">1.0</span>x</label>
|
||||
<input type="range"
|
||||
class="node-slider"
|
||||
data-node="${nodeId}"
|
||||
data-param="0"
|
||||
min="0"
|
||||
max="2"
|
||||
value="1"
|
||||
step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
Mixer: {
|
||||
name: 'Mixer',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Mix up to 4 audio inputs with independent gain controls',
|
||||
inputs: [
|
||||
{ name: 'Input 1', type: SignalType.AUDIO, index: 0 },
|
||||
{ name: 'Input 2', type: SignalType.AUDIO, index: 1 },
|
||||
{ name: 'Input 3', type: SignalType.AUDIO, index: 2 },
|
||||
{ name: 'Input 4', type: SignalType.AUDIO, index: 3 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Mixed Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'gain1', label: 'Gain 1', min: 0, max: 2, default: 1, unit: 'x' },
|
||||
{ id: 1, name: 'gain2', label: 'Gain 2', min: 0, max: 2, default: 1, unit: 'x' },
|
||||
{ id: 2, name: 'gain3', label: 'Gain 3', min: 0, max: 2, default: 1, unit: 'x' },
|
||||
{ id: 3, name: 'gain4', label: 'Gain 4', min: 0, max: 2, default: 1, unit: 'x' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Mixer</div>
|
||||
<div class="node-param">
|
||||
<label>Gain 1: <span id="g1-${nodeId}">1.0</span>x</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0" max="2" value="1" step="0.01">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Gain 2: <span id="g2-${nodeId}">1.0</span>x</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="2" value="1" step="0.01">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Gain 3: <span id="g3-${nodeId}">1.0</span>x</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="2" value="1" step="0.01">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Gain 4: <span id="g4-${nodeId}">1.0</span>x</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="3" min="0" max="2" value="1" step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
Filter: {
|
||||
name: 'Filter',
|
||||
category: NodeCategory.EFFECT,
|
||||
description: 'Biquad filter with lowpass/highpass modes',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 },
|
||||
{ name: 'Cutoff CV', type: SignalType.CV, index: 1 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'cutoff', label: 'Cutoff', min: 20, max: 20000, default: 1000, unit: 'Hz' },
|
||||
{ id: 1, name: 'resonance', label: 'Resonance', min: 0.1, max: 10, default: 0.707, unit: 'Q' },
|
||||
{ id: 2, name: 'type', label: 'Type', min: 0, max: 1, default: 0, unit: '' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Filter</div>
|
||||
<div class="node-param">
|
||||
<label>Cutoff: <span id="cutoff-${nodeId}">1000</span> Hz</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="20" max="20000" value="1000" step="1">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Resonance: <span id="res-${nodeId}">0.707</span></label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.1" max="10" value="0.707" step="0.01">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Type: <span id="ftype-${nodeId}">LP</span></label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="1" value="0" step="1">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
ADSR: {
|
||||
name: 'ADSR',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Attack-Decay-Sustain-Release envelope generator',
|
||||
inputs: [
|
||||
{ name: 'Gate', type: SignalType.CV, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Envelope', type: SignalType.CV, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'attack', label: 'Attack', min: 0.001, max: 5, default: 0.01, unit: 's' },
|
||||
{ id: 1, name: 'decay', label: 'Decay', min: 0.001, max: 5, default: 0.1, unit: 's' },
|
||||
{ id: 2, name: 'sustain', label: 'Sustain', min: 0, max: 1, default: 0.7, unit: '' },
|
||||
{ id: 3, name: 'release', label: 'Release', min: 0.001, max: 5, default: 0.2, unit: 's' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">ADSR</div>
|
||||
<div class="node-param">
|
||||
<label>A: <span id="a-${nodeId}">0.01</span>s</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0.001" max="5" value="0.01" step="0.001">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>D: <span id="d-${nodeId}">0.1</span>s</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.001" max="5" value="0.1" step="0.001">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>S: <span id="s-${nodeId}">0.7</span></label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.7" step="0.01">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>R: <span id="r-${nodeId}">0.2</span>s</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="3" min="0.001" max="5" value="0.2" step="0.001">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
MidiInput: {
|
||||
name: 'MidiInput',
|
||||
category: NodeCategory.INPUT,
|
||||
description: 'MIDI input - receives MIDI events from track',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{ name: 'MIDI Out', type: SignalType.MIDI, index: 0 }
|
||||
],
|
||||
parameters: [],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">MIDI Input</div>
|
||||
<div class="node-info">Receives MIDI from track</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
MidiToCV: {
|
||||
name: 'MidiToCV',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Convert MIDI notes to CV signals',
|
||||
inputs: [
|
||||
{ name: 'MIDI In', type: SignalType.MIDI, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'V/Oct', type: SignalType.CV, index: 0 },
|
||||
{ name: 'Gate', type: SignalType.CV, index: 1 },
|
||||
{ name: 'Velocity', type: SignalType.CV, index: 2 }
|
||||
],
|
||||
parameters: [],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">MIDI→CV</div>
|
||||
<div class="node-info">Converts MIDI to CV signals</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
AudioToCV: {
|
||||
name: 'AudioToCV',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Envelope follower - converts audio amplitude to CV',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'CV Out', type: SignalType.CV, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'attack', label: 'Attack', min: 0.001, max: 1.0, default: 0.01, unit: 's' },
|
||||
{ id: 1, name: 'release', label: 'Release', min: 0.001, max: 1.0, default: 0.1, unit: 's' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Audio→CV</div>
|
||||
<div class="node-param">
|
||||
<label>Attack: <span id="att-${nodeId}">0.01</span>s</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0.001" max="1.0" value="0.01" step="0.001">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Release: <span id="rel-${nodeId}">0.1</span>s</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.001" max="1.0" value="0.1" step="0.001">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
Oscilloscope: {
|
||||
name: 'Oscilloscope',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Visual audio signal monitor (pass-through)',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'time_scale', label: 'Time Scale', min: 10, max: 1000, default: 100, unit: 'ms' },
|
||||
{ id: 1, name: 'trigger_mode', label: 'Trigger', min: 0, max: 2, default: 0, unit: '' },
|
||||
{ id: 2, name: 'trigger_level', label: 'Trigger Level', min: -1, max: 1, default: 0, unit: '' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Oscilloscope</div>
|
||||
<div class="node-param">
|
||||
<label>Time: <span id="time-${nodeId}">100</span>ms</label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="10" max="1000" value="100" step="10">
|
||||
</div>
|
||||
<div class="node-param">
|
||||
<label>Trigger: <span id="trig-${nodeId}">Free</span></label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="2" value="0" step="1">
|
||||
</div>
|
||||
<div class="node-info" style="margin-top: 4px; font-size: 10px;">Pass-through monitor</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
VoiceAllocator: {
|
||||
name: 'VoiceAllocator',
|
||||
category: NodeCategory.UTILITY,
|
||||
description: 'Polyphonic voice allocator - creates N instances of internal graph',
|
||||
inputs: [
|
||||
{ name: 'MIDI In', type: SignalType.MIDI, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Mixed Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [
|
||||
{ id: 0, name: 'voices', label: 'Voices', min: 1, max: 16, default: 8, unit: '' }
|
||||
],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="voice-allocator-header">
|
||||
<div class="node-title">Voice Allocator</div>
|
||||
<div class="node-param">
|
||||
<label>Voices: <span id="voices-${nodeId}">8</span></label>
|
||||
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="1" max="16" value="8" step="1">
|
||||
</div>
|
||||
<div class="node-info" style="margin-top: 4px; font-size: 10px;">Double-click to edit</div>
|
||||
</div>
|
||||
<div class="voice-allocator-contents" id="voice-allocator-contents-${nodeId}" style="display: none;">
|
||||
<div class="node-info" style="font-size: 10px; color: #aaa; margin-bottom: 8px;">Build a synth voice template:</div>
|
||||
<div class="node-info" style="font-size: 9px; color: #c77dff;">Purple nodes are Template Input/Output (non-deletable)</div>
|
||||
<div class="node-info" style="font-size: 9px; color: #888;">Connect MIDI from Template Input → MidiToCV</div>
|
||||
<div class="node-info" style="font-size: 9px; color: #888;">Add synth nodes: Oscillator, ADSR, Gain, etc.</div>
|
||||
<div class="node-info" style="font-size: 9px; color: #888;">Connect final audio → Template Output</div>
|
||||
<div class="node-info" style="font-size: 9px; color: #666; margin-top: 8px;">Drag nodes from palette • Container auto-resizes</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
AudioOutput: {
|
||||
name: 'AudioOutput',
|
||||
category: NodeCategory.OUTPUT,
|
||||
description: 'Final audio output',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
outputs: [
|
||||
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
parameters: [],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Audio Output</div>
|
||||
<div class="node-info">Final output to speakers</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
TemplateInput: {
|
||||
name: 'TemplateInput',
|
||||
category: NodeCategory.INPUT,
|
||||
description: 'VoiceAllocator template input - receives MIDI for one voice',
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{ name: 'MIDI Out', type: SignalType.MIDI, index: 0 }
|
||||
],
|
||||
parameters: [],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Template Input</div>
|
||||
<div class="node-info" style="font-size: 9px;">MIDI for one voice</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
TemplateOutput: {
|
||||
name: 'TemplateOutput',
|
||||
category: NodeCategory.OUTPUT,
|
||||
description: 'VoiceAllocator template output - sends audio to voice mixer',
|
||||
inputs: [
|
||||
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
|
||||
],
|
||||
outputs: [],
|
||||
parameters: [],
|
||||
getHTML: (nodeId) => `
|
||||
<div class="node-content">
|
||||
<div class="node-title">Template Output</div>
|
||||
<div class="node-info" style="font-size: 9px;">Audio to mixer</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all node types in a specific category
|
||||
*/
|
||||
export function getNodesByCategory(category) {
|
||||
return Object.entries(nodeTypes)
|
||||
.filter(([_, def]) => def.category === category)
|
||||
.map(([type, def]) => ({ type, ...def }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all categories that have nodes
|
||||
*/
|
||||
export function getCategories() {
|
||||
const categories = new Set();
|
||||
Object.values(nodeTypes).forEach(def => categories.add(def.category));
|
||||
return Array.from(categories);
|
||||
}
|
||||
+269
@@ -1038,3 +1038,272 @@ button {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
NODE EDITOR STYLES
|
||||
============================================ */
|
||||
|
||||
/* Node editor container */
|
||||
#node-editor-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: #1e1e1e;
|
||||
}
|
||||
|
||||
/* Node palette */
|
||||
.node-palette {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
background: #2d2d2d;
|
||||
border: 1px solid #3d3d3d;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
max-width: 200px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.node-palette h3 {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.node-palette-item {
|
||||
padding: 6px 8px;
|
||||
margin: 4px 0;
|
||||
background: #3d3d3d;
|
||||
border: 1px solid #4d4d4d;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
color: #ddd;
|
||||
font-size: 13px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.node-palette-item:hover {
|
||||
background: #4d4d4d;
|
||||
}
|
||||
|
||||
.node-palette-item:active {
|
||||
background: #5d5d5d;
|
||||
}
|
||||
|
||||
/* Node content styling */
|
||||
.node-content {
|
||||
padding: 8px;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
/* Expanded VoiceAllocator node */
|
||||
.drawflow .drawflow-node.expanded {
|
||||
background: rgba(60, 60, 80, 0.95) !important;
|
||||
border: 2px solid #7c7cff !important;
|
||||
box-shadow: 0 0 20px rgba(124, 124, 255, 0.4);
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.expanded .node-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.expanded .voice-allocator-contents {
|
||||
flex: 1;
|
||||
background: rgba(40, 40, 50, 0.8);
|
||||
border-radius: 4px;
|
||||
margin-top: 8px;
|
||||
padding: 8px;
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Child nodes (inside VoiceAllocator) */
|
||||
.drawflow .drawflow-node.child-node {
|
||||
opacity: 0.9;
|
||||
border: 1px solid #5a5aaa !important;
|
||||
box-shadow: 0 2px 8px rgba(90, 90, 170, 0.3);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.child-node .node-title {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* Template nodes (non-deletable I/O nodes) */
|
||||
.drawflow .drawflow-node.template-node {
|
||||
border: 2px solid #9d4edd !important;
|
||||
background: rgba(157, 78, 221, 0.15) !important;
|
||||
box-shadow: 0 0 12px rgba(157, 78, 221, 0.4);
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.template-node .node-title {
|
||||
color: #c77dff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.node-title {
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.node-info {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.node-param {
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
.node-param label {
|
||||
display: block;
|
||||
font-size: 10px;
|
||||
color: #ccc;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.node-slider {
|
||||
width: calc(100% - 8px);
|
||||
max-width: 140px;
|
||||
height: 3px;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
background: #4d4d4d;
|
||||
outline: none;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.node-slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: #4CAF50;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.node-slider::-moz-range-thumb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: #4CAF50;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Signal Type Connectors */
|
||||
|
||||
/* Audio ports - Blue circles (matches audio clips) */
|
||||
.connector-audio {
|
||||
width: 14px !important;
|
||||
height: 14px !important;
|
||||
border-radius: 50% !important;
|
||||
background: #2196F3 !important;
|
||||
border: 2px solid #1565C0 !important;
|
||||
}
|
||||
|
||||
/* MIDI ports - Green squares (matches MIDI clips) */
|
||||
.connector-midi {
|
||||
width: 14px !important;
|
||||
height: 14px !important;
|
||||
border-radius: 2px !important;
|
||||
background: #4CAF50 !important;
|
||||
border: 2px solid #2E7D32 !important;
|
||||
}
|
||||
|
||||
/* CV ports - Orange diamonds */
|
||||
.connector-cv {
|
||||
width: 12px !important;
|
||||
height: 12px !important;
|
||||
background: #FF9800 !important;
|
||||
border: 2px solid #E65100 !important;
|
||||
transform: rotate(45deg) !important;
|
||||
border-radius: 2px !important;
|
||||
}
|
||||
|
||||
/* Connection line styling - Override Drawflow defaults */
|
||||
.drawflow .connection .main-path {
|
||||
stroke-width: 3px;
|
||||
}
|
||||
|
||||
.connection-audio .main-path {
|
||||
stroke: #2196F3 !important;
|
||||
stroke-width: 4px !important;
|
||||
}
|
||||
|
||||
.connection-midi .main-path {
|
||||
stroke: #4CAF50 !important;
|
||||
stroke-width: 3px !important;
|
||||
stroke-dasharray: 8, 4 !important;
|
||||
}
|
||||
|
||||
.connection-cv .main-path {
|
||||
stroke: #FF9800 !important;
|
||||
stroke-width: 2px !important;
|
||||
}
|
||||
|
||||
/* Port label text styling - position labels away from connectors */
|
||||
.drawflow .drawflow-node .input > span,
|
||||
.drawflow .drawflow-node .output > span {
|
||||
font-size: 9px;
|
||||
color: #999;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
line-height: 20px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
/* Input labels - position to the right of the connector */
|
||||
.drawflow .drawflow-node .input > span {
|
||||
left: 24px;
|
||||
}
|
||||
|
||||
/* Output labels - position to the left of the connector */
|
||||
.drawflow .drawflow-node .output > span {
|
||||
right: 24px;
|
||||
}
|
||||
|
||||
/* Node styling overrides for Drawflow */
|
||||
.drawflow .drawflow-node {
|
||||
background: #2d2d2d !important;
|
||||
border: 2px solid #4d4d4d !important;
|
||||
border-radius: 6px !important;
|
||||
color: #ddd !important;
|
||||
padding: 8px !important;
|
||||
}
|
||||
|
||||
.drawflow .drawflow-node.selected {
|
||||
border-color: #4CAF50 !important;
|
||||
box-shadow: 0 0 10px rgba(76, 175, 80, 0.5) !important;
|
||||
}
|
||||
|
||||
/* Error message styling */
|
||||
.node-editor-error {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: rgba(244, 67, 54, 0.9);
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
z-index: 200;
|
||||
animation: fadeOut 3s forwards;
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
0%, 70% { opacity: 1; }
|
||||
100% { opacity: 0; }
|
||||
}
|
||||
|
||||
+4
-3
@@ -4146,9 +4146,10 @@ class VirtualPiano extends Widget {
|
||||
}
|
||||
|
||||
if (info.isBlack) {
|
||||
// Black key positioning - place it between the white keys
|
||||
// The black key goes after the white key at position whiteKeysBefore
|
||||
const x = offsetX + whiteKeysBefore * whiteKeyWidth + whiteKeyWidth - blackKeyWidth / 2;
|
||||
// Black key positioning - place it at the right edge of the preceding white key
|
||||
// whiteKeysBefore is the number of white keys to the left, so multiply by width
|
||||
// and subtract half the black key width to center it at the gap
|
||||
const x = offsetX + whiteKeysBefore * whiteKeyWidth - blackKeyWidth / 2;
|
||||
|
||||
return {
|
||||
x,
|
||||
|
||||
Reference in New Issue
Block a user