Documentation
¶
Overview ¶
Package modulator provides a unified modulation engine for DMX channel control. It replaces the fade engine with a priority-based effect system where everything (crossfades, waveforms, static looks, system controls) is treated as an effect.
Index ¶
- Constants
- Variables
- func ApplyComposition(existing, effectValue int, mode CompositionMode, hasExisting bool) int
- func ApplyCompositionFloat(existing, effectValue float64, mode CompositionMode, hasExisting bool) float64
- func ApplyEasing(progress float64, easingType EasingType) float64
- func CalculateCrossfadeValues(active *ActiveEffect) map[ChannelKey]int
- func CalculateWaveformValues(active *ActiveEffect, elapsed time.Duration) map[ChannelKey]int
- func GenerateWaveform(phase float64, waveform WaveformType) float64
- func GetCrossfadeRemainingTime(active *ActiveEffect) time.Duration
- func Interpolate(start, end, progress float64, easingType EasingType) float64
- func IsCrossfadeComplete(active *ActiveEffect) bool
- func MergeCrossfadeValues(active *ActiveEffect, existing map[ChannelKey]ChannelState)
- func MergeWaveformValues(active *ActiveEffect, elapsed time.Duration, ...)
- type ActiveEffect
- func (a *ActiveEffect) FadeBlendIn(fromValues map[ChannelKey]int, duration time.Duration, easing EasingType)
- func (a *ActiveEffect) FadeIntensityTo(target float64, duration time.Duration, easing EasingType)
- func (a *ActiveEffect) FadeOutputTo(target float64, duration time.Duration, easing EasingType)
- func (a *ActiveEffect) GetBlendFactor() float64
- func (a *ActiveEffect) GetBlendFromValue(key ChannelKey) (int, bool)
- func (a *ActiveEffect) GetCachedValues() map[ChannelKey]int
- func (a *ActiveEffect) GetCurrentIntensity() float64
- func (a *ActiveEffect) GetOutputContribution() float64
- func (a *ActiveEffect) GetProgress() float64
- func (a *ActiveEffect) IsBlending() bool
- func (a *ActiveEffect) IsComplete() bool
- func (a *ActiveEffect) IsFadingOut() bool
- func (a *ActiveEffect) SetCachedValues(values map[ChannelKey]int)
- func (a *ActiveEffect) UpdateIntensityFromFade()
- type ChannelKey
- type ChannelState
- type CompositionMode
- type CueTransitionRequest
- type EasingType
- type Effect
- type EffectChannel
- type EffectParamUpdate
- type EffectPriority
- type EffectType
- type Engine
- func (e *Engine) ActivateBlackout(fadeTime float64)
- func (e *Engine) ActiveFadeCount() int
- func (e *Engine) AddEffect(effect *Effect) *ActiveEffect
- func (e *Engine) ApplyTransitionBehaviors(fadeTime float64, easing EasingType)
- func (e *Engine) CancelAllFades()
- func (e *Engine) CancelFade(fadeID string)
- func (e *Engine) CleanupCompletedEffects() int
- func (e *Engine) ClearAllEffects()
- func (e *Engine) ClearSystemEffects()
- func (e *Engine) CrossfadeEffectParams(effectID string, newParams EffectParamUpdate, duration time.Duration, ...) bool
- func (e *Engine) ExecuteCueTransition(req CueTransitionRequest) error
- func (e *Engine) FadeToBlack(duration time.Duration, easingType EasingType) string
- func (e *Engine) FadeToLook(channels []LookChannel, duration time.Duration, fadeID string, ...) string
- func (e *Engine) GetActiveEffectCount() int
- func (e *Engine) GetActiveEffects() []*ActiveEffect
- func (e *Engine) GetBlackoutIntensity() float64
- func (e *Engine) GetEffectsByBand(band PriorityBand) []*ActiveEffect
- func (e *Engine) GetEffectsByTransitionBehavior(behavior TransitionBehavior) []*ActiveEffect
- func (e *Engine) GetGrandMasterValue() float64
- func (e *Engine) GetTransitionProgress() float64
- func (e *Engine) GetUpdateRateHz() int
- func (e *Engine) HasActiveTransition() bool
- func (e *Engine) HasSystemEffect(effectID string) bool
- func (e *Engine) IsBlackoutActive() bool
- func (e *Engine) IsRunning() bool
- func (e *Engine) ReleaseBlackout(fadeTime float64)
- func (e *Engine) RemoveEffect(effectID string)
- func (e *Engine) SetGrandMaster(value float64)
- func (e *Engine) SetOnEffectComplete(callback func(effectID string))
- func (e *Engine) SetOnStateChange(callback func())
- func (e *Engine) SetUpdateRate(rateHz int) error
- func (e *Engine) Start() error
- func (e *Engine) Stop() error
- type FadeTransition
- type LookChannel
- type PriorityBand
- type TransitionBehavior
- type WaveformType
Constants ¶
const ( FadeBehaviorFade = "FADE" // Interpolate smoothly between values (default) FadeBehaviorSnap = "SNAP" // Jump to target value at start of transition FadeBehaviorSnapEnd = "SNAP_END" // Jump to target value at end of transition )
FadeBehavior constants for backward compatibility with fade engine.
const ( // SystemBlackoutEffectID is the well-known ID for the blackout effect SystemBlackoutEffectID = "system-blackout" // SystemGrandMasterEffectID is the well-known ID for the grand master effect SystemGrandMasterEffectID = "system-grand-master" )
System effect IDs are well-known constants for identification
const DefaultEasing = EasingInOutSine
DefaultEasing is the default easing type used when none is specified.
const DefaultUpdateRateHz = 60
DefaultUpdateRateHz is the default update rate for the modulation engine.
Variables ¶
var ( // PriorityUserDefault is the default priority for user-activated effects. PriorityUserDefault = NewEffectPriority(PriorityBandUser, 50) // PriorityCueDefault is the default priority for cue crossfades. PriorityCueDefault = NewEffectPriority(PriorityBandCue, 50) // PriorityBlackout is the priority for system blackout (highest). PriorityBlackout = NewEffectPriority(PriorityBandSystem, 100) // PriorityGrandMaster is the priority for grand master. PriorityGrandMaster = NewEffectPriority(PriorityBandSystem, 50) )
Default priorities for common use cases
Functions ¶
func ApplyComposition ¶
func ApplyComposition(existing, effectValue int, mode CompositionMode, hasExisting bool) int
ApplyComposition applies the composition mode to combine an existing value with an effect value.
Parameters:
- existing: the current channel value (from lower priority effects)
- effectValue: the value from this effect
- mode: how to combine the values
- hasExisting: true if there was a previous value for this channel
Returns the composed value, clamped to 0-255.
func ApplyCompositionFloat ¶
func ApplyCompositionFloat(existing, effectValue float64, mode CompositionMode, hasExisting bool) float64
ApplyCompositionFloat is like ApplyComposition but works with float values. This is useful for intermediate calculations before final DMX output.
func ApplyEasing ¶
func ApplyEasing(progress float64, easingType EasingType) float64
ApplyEasing applies an easing function to a progress value (0-1). Returns a value in the range 0-1 that represents the eased progress.
func CalculateCrossfadeValues ¶
func CalculateCrossfadeValues(active *ActiveEffect) map[ChannelKey]int
CalculateCrossfadeValues returns current interpolated values for a crossfade effect.
func CalculateWaveformValues ¶
func CalculateWaveformValues(active *ActiveEffect, elapsed time.Duration) map[ChannelKey]int
CalculateWaveformValues returns modulated channel values for a waveform effect.
func GenerateWaveform ¶
func GenerateWaveform(phase float64, waveform WaveformType) float64
GenerateWaveform returns a value 0-1 for the given phase (0-360 degrees).
func GetCrossfadeRemainingTime ¶
func GetCrossfadeRemainingTime(active *ActiveEffect) time.Duration
GetCrossfadeRemainingTime returns the remaining time for a crossfade.
func Interpolate ¶
func Interpolate(start, end, progress float64, easingType EasingType) float64
Interpolate calculates an interpolated value between start and end.
func IsCrossfadeComplete ¶
func IsCrossfadeComplete(active *ActiveEffect) bool
IsCrossfadeComplete returns true if the crossfade has finished.
func MergeCrossfadeValues ¶
func MergeCrossfadeValues( active *ActiveEffect, existing map[ChannelKey]ChannelState, )
MergeCrossfadeValues merges crossfade values into an existing channel state map. Uses the effect's composition mode to determine how values combine.
func MergeWaveformValues ¶
func MergeWaveformValues( active *ActiveEffect, elapsed time.Duration, existing map[ChannelKey]ChannelState, )
MergeWaveformValues merges waveform values into an existing channel state map.
Types ¶
type ActiveEffect ¶
type ActiveEffect struct {
Effect *Effect
StartTime time.Time
// Runtime state
Intensity float64 // Current intensity (0-100)
Phase float64 // Current phase for waveforms (0-360)
// For crossfades
FromValues map[ChannelKey]int
ToValues map[ChannelKey]int
Duration time.Duration
// Intensity fading
IntensityFade *FadeTransition
// Blend fade - for smoothly fading in the entire effect output (not just amplitude)
// When active, the effect output is blended from BlendFromValues to full effect output
BlendFade *FadeTransition
BlendFromValues map[ChannelKey]int // Channel values to blend from (captured when effect starts)
// Output fade - for fading out the effect's contribution to the final output
// Unlike intensity (which only affects amplitude), this fades the entire effect including offset
// When fading out, the effect's output is blended with the underlying values
OutputFade *FadeTransition
// contains filtered or unexported fields
}
ActiveEffect represents a running effect instance.
func CreateCrossfadeActive ¶
func CreateCrossfadeActive( fromValues map[ChannelKey]int, toValues map[ChannelKey]int, duration time.Duration, easingType EasingType, ) *ActiveEffect
CreateCrossfadeActive creates an active crossfade effect with the given values.
func NewActiveEffect ¶
func NewActiveEffect(effect *Effect) *ActiveEffect
NewActiveEffect creates a new active effect instance.
func (*ActiveEffect) FadeBlendIn ¶
func (a *ActiveEffect) FadeBlendIn(fromValues map[ChannelKey]int, duration time.Duration, easing EasingType)
FadeBlendIn starts a blend-in transition for the entire effect output. This smoothly transitions from the provided base values to the full effect output. Unlike FadeIntensityTo which only scales amplitude, this blends ALL effect output including offset.
func (*ActiveEffect) FadeIntensityTo ¶
func (a *ActiveEffect) FadeIntensityTo(target float64, duration time.Duration, easing EasingType)
FadeIntensityTo starts a fade of the effect's intensity.
func (*ActiveEffect) FadeOutputTo ¶
func (a *ActiveEffect) FadeOutputTo(target float64, duration time.Duration, easing EasingType)
FadeOutputTo starts a fade of the effect's output contribution. Unlike FadeIntensityTo which only affects oscillation amplitude, this fades the entire effect output including offset. Use this for smooth fade-out that blends back to underlying values.
func (*ActiveEffect) GetBlendFactor ¶
func (a *ActiveEffect) GetBlendFactor() float64
GetBlendFactor returns the current blend factor (0-1). Returns 1.0 if no blend fade is active (effect at full contribution).
func (*ActiveEffect) GetBlendFromValue ¶
func (a *ActiveEffect) GetBlendFromValue(key ChannelKey) (int, bool)
GetBlendFromValue returns the "from" value for a specific channel during blend-in.
func (*ActiveEffect) GetCachedValues ¶
func (a *ActiveEffect) GetCachedValues() map[ChannelKey]int
GetCachedValues returns the cached channel values.
func (*ActiveEffect) GetCurrentIntensity ¶
func (a *ActiveEffect) GetCurrentIntensity() float64
GetCurrentIntensity returns the current intensity, accounting for any active fade.
func (*ActiveEffect) GetOutputContribution ¶
func (a *ActiveEffect) GetOutputContribution() float64
GetOutputContribution returns the current output contribution factor (0-1). Returns 1.0 if no output fade is active (effect at full contribution). This is used during composition to blend effect output with underlying values.
func (*ActiveEffect) GetProgress ¶
func (a *ActiveEffect) GetProgress() float64
GetProgress returns the progress of the effect (0-1). For crossfades, this is based on duration. For others, it's always 1.
func (*ActiveEffect) IsBlending ¶
func (a *ActiveEffect) IsBlending() bool
IsBlending returns true if the effect is currently blending in.
func (*ActiveEffect) IsComplete ¶
func (a *ActiveEffect) IsComplete() bool
IsComplete returns true if the effect has finished and should be removed.
func (*ActiveEffect) IsFadingOut ¶
func (a *ActiveEffect) IsFadingOut() bool
IsFadingOut returns true if the effect is currently fading out.
func (*ActiveEffect) SetCachedValues ¶
func (a *ActiveEffect) SetCachedValues(values map[ChannelKey]int)
SetCachedValues stores calculated channel values for later use.
func (*ActiveEffect) UpdateIntensityFromFade ¶
func (a *ActiveEffect) UpdateIntensityFromFade()
UpdateIntensityFromFade updates the intensity if there's an active fade.
type ChannelKey ¶
ChannelKey uniquely identifies a DMX channel across universes.
type ChannelState ¶
type ChannelState struct {
Value int
OwnerEffectID string
CompositionMode CompositionMode
}
ChannelState tracks the current value of a channel and its source.
type CompositionMode ¶
type CompositionMode string
CompositionMode determines how an effect combines with lower-priority effects.
const ( // ComposeModeOverride means the effect completely replaces lower priority values. // This is the default mode for most effects including crossfades and blackout. ComposeModeOverride CompositionMode = "OVERRIDE" // ComposeModeAdditive means the effect adds its value to the existing value. // Useful for chase pulses and flashes layered on a base look. // Final value is clamped to 0-255. ComposeModeAdditive CompositionMode = "ADDITIVE" // ComposeModeMultiply means the effect scales the existing value. // The effect value is treated as a multiplier: 255 = 1.0, 0 = 0.0. // Used for grand master and dimmer curves. ComposeModeMultiply CompositionMode = "MULTIPLY" // ComposeModeModulate means the effect modulates the existing value. // The effect value is centered at 128: 128 = no change, 255 = +127, 0 = -128. // Perfect for LFO waveforms that oscillate around the underlying value. ComposeModeModulate CompositionMode = "MODULATE" )
func ParseCompositionMode ¶
func ParseCompositionMode(s string) CompositionMode
ParseCompositionMode parses a string into a CompositionMode.
func (CompositionMode) IsValid ¶
func (c CompositionMode) IsValid() bool
IsValid returns true if the composition mode is a known valid mode.
func (CompositionMode) String ¶
func (c CompositionMode) String() string
String returns the string representation of the composition mode.
type CueTransitionRequest ¶
type CueTransitionRequest struct {
FromCueID *string // Current cue (nil if starting fresh)
ToCueID *string // Target cue (nil for fade to black)
ToLookValues map[ChannelKey]int // Pre-computed target values
FadeTime float64 // Transition duration in seconds
EasingType EasingType
}
CueTransitionRequest encapsulates parameters for a cue transition.
type EasingType ¶
type EasingType string
EasingType represents the type of easing function to use for fades and transitions.
const ( // EasingLinear provides constant rate of change. EasingLinear EasingType = "LINEAR" // EasingInOutCubic provides smooth acceleration and deceleration. EasingInOutCubic EasingType = "EASE_IN_OUT_CUBIC" // EasingInOutSine provides gentle sine wave easing. // This is the default easing for crossfades. EasingInOutSine EasingType = "EASE_IN_OUT_SINE" // EasingOutExponential provides sharp start, smooth end. EasingOutExponential EasingType = "EASE_OUT_EXPONENTIAL" // EasingBezier provides bezier curve easing. EasingBezier EasingType = "BEZIER" // EasingSCurve provides sigmoid function easing. EasingSCurve EasingType = "S_CURVE" )
func ParseEasingType ¶
func ParseEasingType(s string) EasingType
ParseEasingType parses a string into an EasingType.
func (EasingType) IsValid ¶
func (e EasingType) IsValid() bool
IsValid returns true if the easing type is a known valid type.
func (EasingType) String ¶
func (e EasingType) String() string
String returns the string representation of the easing type.
type Effect ¶
type Effect struct {
ID string
Name string
Description string
ProjectID string
// Type and behavior
EffectType EffectType
Priority EffectPriority
CompositionMode CompositionMode
OnCueChange TransitionBehavior
FadeDuration *float64 // Override cue fadeInTime if set
// Easing (for CROSSFADE type)
EasingType EasingType
// Waveform parameters (for WAVEFORM type)
Waveform WaveformType
Frequency float64 // Hz
Amplitude float64 // 0-100%
Offset float64 // 0-100% baseline
PhaseOffset float64 // 0-360 degrees
// For MASTER type
MasterValue float64 // 0.0-1.0 multiplier
// Channel targets
TargetChannels []EffectChannel
}
Effect represents an effect definition. Effects can be waveform-based (LFO), crossfades, static values, or master faders.
func CreateBlackoutEffect ¶
func CreateBlackoutEffect() *Effect
CreateBlackoutEffect creates a STATIC effect at SYSTEM priority that zeros all channels. When active at full intensity, it overrides all other effects and sets all channels to 0. The blackout effect uses PERSIST behavior so it doesn't fade out on cue changes.
func CreateCrossfadeEffect ¶
func CreateCrossfadeEffect( fromValues map[ChannelKey]int, toValues map[ChannelKey]int, duration time.Duration, easingType EasingType, ) *Effect
CreateCrossfadeEffect creates a crossfade effect from current state to target.
func CreateGrandMasterEffect ¶
CreateGrandMasterEffect creates a MASTER effect that scales all intensity channels. The value parameter controls the multiplier: 0.0 = all dark, 1.0 = full intensity. Grand master uses PERSIST behavior so it persists across cue changes.
func NewEffect ¶
func NewEffect(effectType EffectType, priority EffectPriority) *Effect
NewEffect creates a new effect with the specified parameters.
type EffectChannel ¶
type EffectChannel struct {
Universe int
Channel int
// Per-channel overrides
PhaseOffset *float64 // Phase offset in degrees (for waveforms)
AmplitudeScale *float64 // Amplitude multiplier (applied to effect's base amplitude)
FrequencyScale *float64 // Frequency multiplier
// Per-channel absolute values (when set, override base effect values instead of scaling)
// These are used when min/max values are specified at the channel level
Offset *float64 // Absolute offset (0-100%), overrides effect's base offset
Amplitude *float64 // Absolute amplitude (0-100%), overrides effect's base amplitude
}
EffectChannel represents channel-specific parameters for an effect.
type EffectParamUpdate ¶
type EffectParamUpdate struct {
Intensity *float64 // Target intensity (0-100)
Frequency *float64 // Target frequency for waveforms
Amplitude *float64 // Target amplitude for waveforms
Offset *float64 // Target offset for waveforms
}
EffectParamUpdate represents parameter updates for CROSSFADE_PARAMS behavior.
type EffectPriority ¶
type EffectPriority struct {
Band PriorityBand
SubPriority int // 0-100, higher values have higher priority within the band
}
EffectPriority represents the complete priority of an effect, consisting of a band and a sub-priority within that band.
func NewEffectPriority ¶
func NewEffectPriority(band PriorityBand, subPriority int) EffectPriority
NewEffectPriority creates a new EffectPriority with the given band and sub-priority. SubPriority is clamped to 0-100.
func (EffectPriority) Compare ¶
func (p EffectPriority) Compare(other EffectPriority) int
Compare compares this priority with another. Returns:
-1 if this priority is lower than other 0 if priorities are equal 1 if this priority is higher than other
func (EffectPriority) Equal ¶
func (p EffectPriority) Equal(other EffectPriority) bool
Equal returns true if this priority equals other.
func (EffectPriority) Greater ¶
func (p EffectPriority) Greater(other EffectPriority) bool
Greater returns true if this priority is higher than other.
func (EffectPriority) Less ¶
func (p EffectPriority) Less(other EffectPriority) bool
Less returns true if this priority is lower than other. Used for sorting effects by priority (lowest first).
type EffectType ¶
type EffectType string
EffectType represents the type of effect, determining its calculation behavior.
const ( // EffectTypeWaveform is an LFO-based continuous modulation using waveforms. EffectTypeWaveform EffectType = "WAVEFORM" // EffectTypeCrossfade interpolates between channel states over time. EffectTypeCrossfade EffectType = "CROSSFADE" // EffectTypeStatic sets channels to fixed values without modulation. EffectTypeStatic EffectType = "STATIC" // EffectTypeMaster is a multiplier effect for intensity scaling (grand master). EffectTypeMaster EffectType = "MASTER" )
func ParseEffectType ¶
func ParseEffectType(s string) EffectType
ParseEffectType parses a string into an EffectType.
func (EffectType) IsValid ¶
func (e EffectType) IsValid() bool
IsValid returns true if the effect type is a known valid type.
func (EffectType) String ¶
func (e EffectType) String() string
String returns the string representation of the effect type.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the unified modulator engine that processes all DMX modulation. It replaces the fade engine with a priority-based effect system.
func NewEngine ¶
NewEngine creates a new modulator engine with the specified update rate. If updateRateHz is <= 0, it defaults to 60Hz.
func (*Engine) ActivateBlackout ¶
ActivateBlackout enables the system blackout effect with an optional fade time. If fadeTime is 0, the blackout is immediate. Otherwise, it fades in over the specified duration.
func (*Engine) ActiveFadeCount ¶
ActiveFadeCount returns the number of active crossfade effects.
func (*Engine) AddEffect ¶
func (e *Engine) AddEffect(effect *Effect) *ActiveEffect
AddEffect adds an effect to the engine.
func (*Engine) ApplyTransitionBehaviors ¶
func (e *Engine) ApplyTransitionBehaviors(fadeTime float64, easing EasingType)
ApplyTransitionBehaviors applies OnCueChange behaviors to all active effects. This is the public version that acquires the lock.
func (*Engine) CancelAllFades ¶
func (e *Engine) CancelAllFades()
CancelAllFades removes all crossfade effects.
func (*Engine) CancelFade ¶
CancelFade removes a specific crossfade by ID.
func (*Engine) CleanupCompletedEffects ¶
CleanupCompletedEffects removes effects that have reached 0 intensity or completed. This is automatically called in processModulation but can be called manually.
func (*Engine) ClearAllEffects ¶
func (e *Engine) ClearAllEffects()
ClearAllEffects removes all active effects.
func (*Engine) ClearSystemEffects ¶
func (e *Engine) ClearSystemEffects()
ClearSystemEffects removes all system-level effects (blackout and grand master). This is useful for resetting the system to a clean state.
func (*Engine) CrossfadeEffectParams ¶
func (e *Engine) CrossfadeEffectParams(effectID string, newParams EffectParamUpdate, duration time.Duration, easing EasingType) bool
CrossfadeEffectParams starts a parameter crossfade for an existing effect. This implements the CROSSFADE_PARAMS transition behavior.
func (*Engine) ExecuteCueTransition ¶
func (e *Engine) ExecuteCueTransition(req CueTransitionRequest) error
ExecuteCueTransition executes a cue transition with proper effect lifecycle management. It handles transition behaviors for existing effects based on their OnCueChange settings.
func (*Engine) FadeToBlack ¶
func (e *Engine) FadeToBlack(duration time.Duration, easingType EasingType) string
FadeToBlack creates a crossfade to all zeros.
func (*Engine) FadeToLook ¶
func (e *Engine) FadeToLook(channels []LookChannel, duration time.Duration, fadeID string, easingType EasingType) string
FadeToLook creates a crossfade effect to the specified look. This provides backward compatibility with the existing fade engine API.
func (*Engine) GetActiveEffectCount ¶
GetActiveEffectCount returns the number of active effects.
func (*Engine) GetActiveEffects ¶
func (e *Engine) GetActiveEffects() []*ActiveEffect
GetActiveEffects returns a copy of all active effects.
func (*Engine) GetBlackoutIntensity ¶
GetBlackoutIntensity returns the current blackout intensity (0-100). Returns 0 if blackout is not active.
func (*Engine) GetEffectsByBand ¶
func (e *Engine) GetEffectsByBand(band PriorityBand) []*ActiveEffect
GetEffectsByBand returns all active effects in a specific priority band.
func (*Engine) GetEffectsByTransitionBehavior ¶
func (e *Engine) GetEffectsByTransitionBehavior(behavior TransitionBehavior) []*ActiveEffect
GetEffectsByTransitionBehavior returns all active effects with a specific transition behavior.
func (*Engine) GetGrandMasterValue ¶
GetGrandMasterValue returns the current grand master level (0.0-1.0). Returns 1.0 if no grand master effect is active.
func (*Engine) GetTransitionProgress ¶
GetTransitionProgress returns the progress (0-1) of the current cue transition. Returns 1.0 if no transition is active.
func (*Engine) GetUpdateRateHz ¶
GetUpdateRateHz returns the current update rate in Hz.
func (*Engine) HasActiveTransition ¶
HasActiveTransition returns true if there's an active cue transition (crossfade) in progress.
func (*Engine) HasSystemEffect ¶
HasSystemEffect returns true if a system effect with the given ID is active.
func (*Engine) IsBlackoutActive ¶
IsBlackoutActive returns true if the blackout effect is currently active. An active blackout is one that exists and has non-zero intensity (or is fading to non-zero).
func (*Engine) ReleaseBlackout ¶
ReleaseBlackout disables the system blackout effect with an optional fade time. If fadeTime is 0, the blackout is released immediately. Otherwise, it fades out over the specified duration.
func (*Engine) RemoveEffect ¶
RemoveEffect removes an effect from the engine by ID.
func (*Engine) SetGrandMaster ¶
SetGrandMaster sets the grand master level (0.0-1.0). If the grand master effect doesn't exist, it creates one. The change is immediate (no fade).
func (*Engine) SetOnEffectComplete ¶
SetOnEffectComplete sets a callback that is called when an effect completes.
func (*Engine) SetOnStateChange ¶
func (e *Engine) SetOnStateChange(callback func())
SetOnStateChange sets a callback that is called when the modulation state changes.
func (*Engine) SetUpdateRate ¶
SetUpdateRate changes the update rate. If the engine is running, it will be stopped and restarted.
type FadeTransition ¶
type FadeTransition struct {
StartValue float64
EndValue float64
Duration time.Duration
StartTime time.Time
EasingType EasingType
}
FadeTransition represents an ongoing intensity or parameter fade.
func (*FadeTransition) CurrentValue ¶
func (f *FadeTransition) CurrentValue() float64
CurrentValue calculates the current interpolated value of the fade.
func (*FadeTransition) IsComplete ¶
func (f *FadeTransition) IsComplete() bool
IsComplete returns true if the fade has finished.
func (*FadeTransition) Progress ¶
func (f *FadeTransition) Progress() float64
Progress returns the current progress of the fade (0-1).
type LookChannel ¶
type LookChannel struct {
Universe int
Channel int
Value int // Target DMX value (0-255)
FadeBehavior string // FADE, SNAP, SNAP_END - defaults to FADE
}
LookChannel matches the existing fade engine's LookChannel struct for compatibility.
type PriorityBand ¶
type PriorityBand int
PriorityBand represents the major priority category of an effect. Higher bands always override lower bands for the same channel.
const ( // PriorityBandBase is the lowest priority: static look values, default state. PriorityBandBase PriorityBand = 0 // PriorityBandUser is for user-activated effects: chase, pulse, color cycle. PriorityBandUser PriorityBand = 1 // PriorityBandCue is for cue transitions: crossfades between looks. PriorityBandCue PriorityBand = 2 // PriorityBandSystem is the highest priority: blackout, grand master, emergency. PriorityBandSystem PriorityBand = 3 )
func ParsePriorityBand ¶
func ParsePriorityBand(s string) PriorityBand
ParsePriorityBand parses a string into a PriorityBand.
func (PriorityBand) String ¶
func (p PriorityBand) String() string
String returns the string representation of the priority band.
type TransitionBehavior ¶
type TransitionBehavior string
TransitionBehavior determines what happens to an effect when a cue change occurs.
const ( // TransitionFadeOut means the effect fades intensity to 0 over the cue's fadeInTime. // This is the default behavior for most effects. TransitionFadeOut TransitionBehavior = "FADE_OUT" // TransitionPersist means the effect continues unchanged until explicitly stopped. // Useful for ambient effects and blackout. TransitionPersist TransitionBehavior = "PERSIST" // TransitionSnapOff means the effect stops immediately when cue changes. // Useful for strobe effects and precise timing. TransitionSnapOff TransitionBehavior = "SNAP_OFF" // TransitionCrossfadeParams means the effect parameters smoothly transition to new values. // Used when the same effect continues but with different intensity/speed. TransitionCrossfadeParams TransitionBehavior = "CROSSFADE_PARAMS" )
func ParseTransitionBehavior ¶
func ParseTransitionBehavior(s string) TransitionBehavior
ParseTransitionBehavior parses a string into a TransitionBehavior.
func (TransitionBehavior) IsImmediate ¶
func (t TransitionBehavior) IsImmediate() bool
IsImmediate returns true if this transition behavior takes effect immediately.
func (TransitionBehavior) IsValid ¶
func (t TransitionBehavior) IsValid() bool
IsValid returns true if the transition behavior is a known valid behavior.
func (TransitionBehavior) RequiresFade ¶
func (t TransitionBehavior) RequiresFade() bool
RequiresFade returns true if this transition behavior involves a fade animation.
func (TransitionBehavior) String ¶
func (t TransitionBehavior) String() string
String returns the string representation of the transition behavior.
type WaveformType ¶
type WaveformType string
WaveformType represents the type of waveform for LFO effects.
const ( // WaveformSine produces a smooth sine wave oscillation. WaveformSine WaveformType = "SINE" // WaveformCosine produces a cosine wave (90° phase-shifted sine). WaveformCosine WaveformType = "COSINE" // WaveformSquare produces a square wave (on/off). WaveformSquare WaveformType = "SQUARE" // WaveformSawtooth produces a sawtooth wave (linear ramp up, instant reset). WaveformSawtooth WaveformType = "SAWTOOTH" // WaveformTriangle produces a triangle wave (linear up, linear down). WaveformTriangle WaveformType = "TRIANGLE" // WaveformRandom produces random values (deterministic based on phase). WaveformRandom WaveformType = "RANDOM" )
func ParseWaveformType ¶
func ParseWaveformType(s string) WaveformType
ParseWaveformType parses a string into a WaveformType.
func (WaveformType) IsValid ¶
func (w WaveformType) IsValid() bool
IsValid returns true if the waveform type is a known valid type.
func (WaveformType) String ¶
func (w WaveformType) String() string
String returns the string representation of the waveform type.