Overview
HNode is built as a Unity application with a modular plugin architecture that processes DMX lighting data in real-time. The system receives Art-Net DMX packets over the network, processes them through customizable generators, serializes the data into video textures, and outputs via Spout for use in other applications.Core Architecture Components
Art-Net Receiver
Listens for incoming Art-Net DMX packets on UDP port 6454 (configurable)
DMX Manager
Manages DMX universe data with support for up to 16,384 channels across multiple universes
Plugin System
Extensible architecture with Serializers, Generators, and Exporters
Texture Pipeline
Converts DMX data to/from video textures using configurable pixel mapping formats
Application Structure
The Unity application follows a centralized architecture with theLoader class serving as the main orchestrator.
Loader (Main Orchestrator)
TheLoader.cs component handles:
- Plugin Discovery: Automatically discovers all implementations of
IDMXSerializer,IDMXGenerator, andIExporterinterfaces using reflection - Configuration Management: Loads and saves show configurations as YAML files (.shwcfg)
- Component Initialization: Sets up Spout receivers/senders, Art-Net receiver, and texture readers/writers
- UI Coordination: Manages dynamic UI generation for all active plugins
Loader.cs:46-49
Show Configuration
TheShowConfiguration class is the heart of HNode’s configuration system, defining:
Serialization Settings
Serialization Settings
- Serializer: Converts DMX bytes to video pixels
- Deserializer: Converts video pixels back to DMX bytes
- Transcode Mode: Enable to convert between different pixel mapping formats
- Universe Counts: Configure how many universes to process
Channel Masking
Channel Masking
- Masked Channels: List<DMXChannelRange> defining channels to hide/show
- Invert Mask: Flip behavior to only show masked channels
- Auto Mask on Zero: Automatically make zero-value channels transparent
Input/Output Configuration
Input/Output Configuration
- Spout Names: Input and output Spout stream names
- Art-Net Settings: IP address (0.0.0.0 for all interfaces) and port
- Resolutions: Separate input/output texture resolutions
- Framerate: Target application framerate (1-60 FPS)
Data Flow Pipeline
HNode processes DMX data through a well-defined pipeline every frame:Art-Net Reception
The
ArtNetReceiver listens on UDP for incoming Art-Net packets. When received, the DmxManager stores the 512-byte universe data in a dictionary keyed by universe number.DmxManager.cs:64-75
DMX Merging
The
TextureWriter merges all universes into a single contiguous List<byte>. In transcode mode, it uses data from the TextureReader instead of Art-Net.TextureWriter.cs:76-96
Generator Processing
Each active
IDMXGenerator modifies the DMX data in sequence. Generators can read, write, or transform channel values.TextureWriter.cs:99-105
Serialization
The active
IDMXSerializer converts each DMX channel value into pixels in a Color32[] array, applying channel masking rules.TextureWriter.cs:113-146
Plugin System
HNode’s extensibility comes from its plugin interface system. All plugins implement:IConstructable Interface
IConstructable.cs:4-8
IUserInterface Interface
Plugins can create custom UI elements that appear in the HNode interface:ConstructUserInterface(RectTransform rect): Create UI elementsDeconstructUserInterface(): Clean up UI elementsUpdateUserInterface(): Update UI values each frame
Plugin Lifecycle
- Discovery: On startup,
Loaderscans all assemblies for interface implementations - Construction: When added to a show configuration,
Construct()is called - Execution: Plugin methods are called each frame during the data pipeline
- Deconstruction: When removed or app closes,
Deconstruct()is called
Transcode Mode
Transcode mode enables format conversion between different pixel mapping standards:In transcode mode, Art-Net input is disabled and the
TextureReader provides DMX data instead of the DmxManager.Configuration Persistence
Show configurations are saved as YAML files with the.shwcfg extension:
Performance Considerations
HNode is optimized for real-time performance:- Unity Profiler Integration: Key sections are wrapped in
Profiler.BeginSample()/EndSample() - Array Pre-allocation: DMX lists use
EnsureCapacity()to avoid resizing - Minimal GC Pressure: Reuses arrays and avoids unnecessary allocations
- Configurable Universe Counts: Limit processing to only needed universes
TextureWriter.cs:166-172