Skip to content

05_11_11_visualization_system - Sistema de VisualizaciΓ³n

Estado: πŸ“‹ Pendiente Prioridad: MEDIA EstimaciΓ³n: 4-6 semanas Dependencias: Todo el subsistema


🎯 PROPΓ“SITO

El Visualization System permite ver y depurar el grafo visualmente, esencial para entender flujos complejos:

  • πŸ‘οΈ Renderizado del grafo con layouts inteligentes
  • πŸ“Š MΓ©tricas en tiempo real (CPU, levels, latency)
  • 🎨 Color-coding por tipo y estado
  • πŸ–±οΈ InteracciΓ³n (select, drag, edit)
  • πŸ“Έ Export a SVG/PNG

Sin visualizaciΓ³n: Debug con printf, confusiΓ³n Con visualizaciΓ³n: Entendimiento inmediato, debug 10x mΓ‘s rΓ‘pido


πŸ“ COMPONENTES

1. Graph Renderer

class GraphRenderer {
    enum LayoutAlgorithm {
        HIERARCHICAL,      // Layered by dependency
        FORCE_DIRECTED,    // Physics simulation
        CIRCULAR          // Nodes in circle
    };

    void setLayout(LayoutAlgorithm algo);
    void render(const AudioGraph& graph, RenderTarget& target);
};

Layout Algorithms:

Hierarchical (Sugiyama): - Best for: DAGs with clear flow - Pros: Shows dependencies clearly - Cons: Not for cyclic graphs

Force-Directed (Fruchterman-Reingold): - Best for: General graphs - Pros: Works for any graph - Cons: Slow for >100 nodes

Circular: - Best for: Feedback-heavy graphs - Pros: Shows cycles clearly - Cons: Can be cluttered

2. Visual Elements

struct NodeVisual {
    Shape shape;           // Circle/Rectangle by type
    Color color;           // By category
    std::string label;
    Position position;

    // Annotations
    float cpuUsage;        // 0-100%
    float peakLevel;       // -inf to 0 dB
    bool isClipping;
    bool isBypassed;
};

struct EdgeVisual {
    LineStyle style;       // Solid=audio, dashed=control
    float width;           // Proportional to channels
    Color color;           // Green=active, gray=muted
    bool animated;         // Show signal flow
};

Visual Language:

Node Shapes: - πŸ”΅ Circle: Sources (input, oscillators) - β–­ Rectangle: Processors (filters, effects) - ⬑ Hexagon: Outputs (DAC, file)

Node Colors: - πŸ”΅ Blue: Input/Source - 🟒 Green: Effects/Processors - 🟑 Yellow: Analysis/Meters - πŸ”΄ Red: Output/Destination - ⚫ Gray: Bypassed

Edge Styles: - ━━━ Solid: Audio signal - β•Œβ•Œβ•Œ Dashed: Control signal - β”„β”„β”„ Dotted: MIDI - ━━━ Thick: Multi-channel

Edge Colors: - 🟒 Green: Active, signal present - ⚫ Gray: Muted or inactive - πŸ”΄ Red: Clipping detected

3. Real-Time Monitor

class GraphMonitor {
    struct NodeMetrics {
        float cpuUsage;           // % of total
        float peakLevel;          // dB
        int processCallsPerSec;
        bool isClipping;
        float latencyMs;
    };

    void updateMetrics();
    void renderOverlay(GraphRenderer& renderer);
};

Metrics Displayed: - CPU usage (color intensity) - Audio levels (meter beside node) - Latency (ms on node) - Clipping warnings (red indicator) - Process rate (calls/sec)

4. Interactive Features

class GraphInteraction {
    NodeID getNodeAtPosition(Point pos);
    void selectNode(NodeID node);
    void dragNode(NodeID node, Point delta);
    void editParameter(NodeID node, const std::string& param);

    // Connection editing
    void startConnection(NodeID from, PortID port);
    void completeConnection(NodeID to, PortID port);
    void deleteConnection(EdgeID edge);
};

Interactions: - πŸ–±οΈ Click node β†’ Select - πŸ–±οΈ Drag node β†’ Move - πŸ–±οΈ Double-click β†’ Edit parameters - πŸ–±οΈ Drag from port β†’ Create connection - ⌨️ Delete key β†’ Remove selected - πŸ–±οΈ Scroll β†’ Zoom - πŸ–±οΈ Middle-drag β†’ Pan

5. Export System

class GraphExporter {
    void exportToSVG(const std::string& path);
    void exportToPNG(const std::string& path, int width, int height);
    void exportToJSON(const std::string& path);  // Structure only
};

πŸ“‚ ESTRUCTURA

05_11_11_visualization_system/
β”œβ”€β”€ include/
β”‚   β”œβ”€β”€ GraphRenderer.h
β”‚   β”œβ”€β”€ LayoutAlgorithm.h
β”‚   β”œβ”€β”€ GraphMonitor.h
β”‚   β”œβ”€β”€ GraphInteraction.h
β”‚   β”œβ”€β”€ GraphExporter.h
β”‚   └── RenderTarget.h          # Abstract interface
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ GraphRenderer.cpp
β”‚   β”œβ”€β”€ HierarchicalLayout.cpp
β”‚   β”œβ”€β”€ ForceDirectedLayout.cpp
β”‚   β”œβ”€β”€ CircularLayout.cpp
β”‚   β”œβ”€β”€ GraphMonitor.cpp
β”‚   β”œβ”€β”€ GraphInteraction.cpp
β”‚   └── GraphExporter.cpp
β”œβ”€β”€ backends/
β”‚   β”œβ”€β”€ OpenGLRenderTarget.cpp
β”‚   β”œβ”€β”€ Direct2DRenderTarget.cpp
β”‚   └── SVGRenderTarget.cpp
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_layouts.cpp
β”‚   β”œβ”€β”€ test_rendering.cpp
β”‚   β”œβ”€β”€ test_interaction.cpp
β”‚   └── test_export.cpp
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ simple_visualizer.cpp
β”‚   β”œβ”€β”€ interactive_editor.cpp
β”‚   └── metrics_overlay.cpp
└── docs/
    β”œβ”€β”€ VISUAL_LANGUAGE.md
    β”œβ”€β”€ LAYOUT_ALGORITHMS.md
    └── INTEGRATION_GUIDE.md

🎯 ENTREGABLES

  • GraphRenderer with 3 layout algorithms
  • NodeVisual and EdgeVisual structures
  • GraphMonitor for real-time metrics
  • Interactive features (select, edit, drag)
  • Export to SVG/PNG
  • OpenGL render backend
  • 10+ unit tests
  • Visual test suite
  • Performance benchmarks
  • User guide with examples

πŸ“Š MΓ‰TRICAS DE Γ‰XITO

Visual Quality

  • βœ… Clear node separation (no overlaps)
  • βœ… Readable labels at all zoom levels
  • βœ… Intuitive color coding
  • βœ… Smooth animations (60 FPS)

Performance

  • βœ… 60 FPS with 100 nodes
  • βœ… 30 FPS with 500 nodes
  • βœ… <100ms layout calculation (100 nodes)

Usability

  • βœ… Intuitive without training
  • βœ… Fast navigation (zoom, pan)
  • βœ… Clear visual hierarchy
  • βœ… Helpful tooltips

Accuracy

  • βœ… Metrics update 10x/sec
  • βœ… <10ms latency for interaction
  • βœ… Precise export (SVG matches display)

πŸ’‘ EJEMPLO VISUAL

     [Input]──────┐
        β”‚         β”‚
        ↓         ↓
     [Gain]    [Filter]
     32%       45%         ← CPU usage
     -12dB     -18dB       ← Peak level
        β”‚         β”‚
        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
             ↓
          [Output]
          15%
          -6dB

Con colores: - Nodos verdes (procesando) - Edges verdes (seΓ±al activa) - NΓΊmeros en blanco (mΓ©tricas) - Background negro (clarity)


🎨 TEMAS VISUALES

Dark Theme (default)

Background: #1e1e1e
Nodes: #2d2d2d
Text: #ffffff
Edges: #4a4a4a
Active: #00ff00
Warning: #ffff00
Error: #ff0000

Light Theme

Background: #ffffff
Nodes: #e0e0e0
Text: #000000
Edges: #808080
Active: #00aa00
Warning: #ffaa00
Error: #cc0000

High Contrast

Background: #000000
Nodes: #ffffff
Text: #000000
Edges: #ffffff
Active: #00ff00
Warning: #ffff00
Error: #ff0000

πŸ–ΌοΈ SCREENSHOTS (Conceptual)

Simple Chain

[Input] β†’ [Gain] β†’ [Filter] β†’ [Output]

Parallel Effects

         β”Œβ”€ [Reverb] ─┐
[Input] ──            β”œβ”€ [Mix] β†’ [Output]
         └─ [Delay] β”€β”€β”˜

Feedback Loop

[Input] β†’ [Delay] β†’ [Filter] β†’ [Output]
            ↑          β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Multi-Band

         β”Œβ”€ [LowBand] ─┐
[Input] ─┼─ [MidBand] ─┼─ [Sum] β†’ [Output]
         └─ [HiBand] β”€β”€β”˜

πŸ”§ CONFIGURACIΓ“N

GraphVisualizer visualizer;

// Layout
visualizer.setLayout(LayoutAlgorithm::HIERARCHICAL);

// Visual options
visualizer.showMetrics(true);
visualizer.showEdgeFlow(true);    // Animate signal flow
visualizer.setColorScheme(ColorScheme::DARK);

// Interaction
visualizer.enableEditing(true);
visualizer.enableDragging(true);

// Render
while (running) {
    visualizer.update(deltaTime);
    visualizer.render(renderTarget);
}

πŸ“ˆ ROADMAP

Fase 1 - Basic Visualization (2 weeks)

  • Static rendering
  • Hierarchical layout
  • Basic colors

Fase 2 - Metrics & Animation (2 weeks)

  • Real-time metrics
  • Animated signal flow
  • CPU/level displays

Fase 3 - Interaction (2 weeks)

  • Selection
  • Dragging
  • Basic editing

Fase 4 - Advanced Features (2 weeks)

  • Additional layouts
  • Export
  • Themes
  • Polish

Creado: 2025-10-14 VersiΓ³n: 1.0.0