diff --git a/frontend/src/components/GraphCanvas.svelte b/frontend/src/components/GraphCanvas.svelte index b6436df..b6a1278 100644 --- a/frontend/src/components/GraphCanvas.svelte +++ b/frontend/src/components/GraphCanvas.svelte @@ -139,17 +139,20 @@ return $patchbay.aliases?.[nd.name] || nd.nick || nd.name; } - // Level meter helpers - function meterDb(nodeId: number): number { + // Graph visibility toggle + let showGraph = $state(true); + + // Level meter: returns how many of `total` segments should be lit + function meterSegs(nodeId: number, total: number): number { const p = $peaks[nodeId] ?? 0; - return p > 0 ? Math.max(-60, 20 * Math.log10(p)) : -60; + if (p <= 0) return 0; + const db = Math.max(-60, 20 * Math.log10(p)); + return Math.round(Math.max(0, (db + 60) / 60) * total); } - function meterWidth(nodeId: number, barW: number): number { - return barW * Math.max(0, (meterDb(nodeId) + 60) / 60); - } - function meterColor(nodeId: number): string { - const db = meterDb(nodeId); - return db >= -3 ? '#c44' : db >= -12 ? '#ca4' : '#4a9'; + // Segment color by position (0 = leftmost/quietest) + function segColor(i: number, total: number): string { + const pct = i / total; + return pct >= 0.90 ? '#c44' : pct >= 0.75 ? '#ca4' : '#4a9'; } // Build computed layout @@ -207,7 +210,7 @@ const headerH = 22; const portH = 16; const maxPorts = Math.max(allInPorts.length, allOutPorts.length, 1); - const height = headerH + maxPorts * portH + 28; // 20 for volume slider + 8 for meter bar + const height = headerH + maxPorts * portH + 36; // 20 for volume slider + 16 for VU meter const width = 220; const portPositions = new Map(); @@ -507,6 +510,8 @@ {$nodes.length}N {$ports.length}P {$links.length}L {#if $patchbay.pinned_connections.length > 0}{$patchbay.pinned_connections.length}p{/if} + + @@ -551,6 +556,7 @@ {/if} + {#if showGraph} - - - + + {#each Array(20) as _, i} + + {/each} {/each} + {/if} {#if contextMenu} @@ -908,11 +923,11 @@