Package heronarts.lx
Class LXEngine
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.LXEngine
- All Implemented Interfaces:
LXPath
,LXSerializable
,LXModulationContainer
,LXOscComponent
,LXParameterListener
The engine is the core class that runs the internal animations. An engine is
comprised of top-level modulators, then a number of channels, each of which
has a set of patterns that it may transition between. These channels are
blended together, and effects are then applied.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
class
class
class
static enum
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Hidden, LXComponent.Placeholder, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
Modifier and TypeFieldDescriptionfinal LXAudioEngine
final LXClipEngine
final LXDmxEngine
final BoundedParameter
final BooleanParameter
final BooleanParameter
final BooleanParameter
final LXMappingEngine
final LXMidiEngine
final LXMixerEngine
final LXModulationEngine
final LXEngine.NetworkThread
long
long
Globally accessible counter of the current millisecond clockfinal LXOscEngine
final LXEngine.Output
final LXPalette
static final String
static final String
final BooleanParameter
final LXEngine.Profiler
final BooleanParameter
final LXSnapshotEngine
final BoundedParameter
final Tempo
Fields inherited from class heronarts.lx.LXComponent
children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFile
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Method Summary
Modifier and TypeMethodDescriptionaddLoopTask
(LXLoopTask loopTask) Add a task to be run on every loop of the engine thread.Sets the output driverAdd a task to be run once on the engine thread.void
Utility method for P4LX mode, invoked from the Processing draw thread to give a chance to change the threading state before the draw loop.void
This should be used when in threaded mode.void
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.float
Gets the active frame rate of the engine when in threaded modefloat
Gets a very rough estimate of the CPU load the engine is using before maxing out.void
Non-thread safe accessor of the render buffer.getPath()
Accessor for the path of this object.boolean
handleOscMessage
(OscMessage message, String[] parts, int index) Handles an OSC message sent to this component.boolean
isPaused()
boolean
Returns whether the engine is actively threadedvoid
load
(LX lx, JsonObject obj) Loads the LX component.void
Utility method to shut down and join the engine thread, only when specifically in P4 mode.void
Subclasses are free to override this if desired.registerComponent
(String path, LXComponent component) Register a component with the engine.removeLoopTask
(LXLoopTask loopTask) Remove a task from the list run on every loop invocationvoid
run()
This is the core run loop of the LXEngine.setFixedDeltaMs
(double deltaMs) Utility for when rendering offline videos.setInputDispatch
(LXEngine.Dispatch inputDispatch) setPaused
(boolean paused) Pause the engine from runningsetSpeed
(double speed) Sets a global speed factor on the core animation engine.setThreaded
(boolean threaded) Sets the engine to threaded or non-threaded mode.void
start()
Starts the engine thread.void
stop()
Stops the engine thread.Methods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, contains, copyParameters, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, hasParameter, isValidOscParameter, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, save, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddress
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
palette
-
tempo
-
clips
-
mixer
-
midi
-
audio
-
mapping
-
osc
-
dmx
-
output
-
framesPerSecond
-
speed
-
performanceMode
-
restricted
-
modulation
-
snapshots
-
profiler
-
isMultithreaded
-
isChannelMultithreaded
-
isNetworkMultithreaded
-
networkThread
-
nowNanoTime
public long nowNanoTimeGlobally accessible counter of the current millisecond clock -
nowMillis
public long nowMillis -
PATH_FRAMERATE
- See Also:
-
PATH_OPEN_PROJECT
- See Also:
-
-
Method Details
-
logProfiler
public void logProfiler() -
getPath
Description copied from class:LXComponent
Accessor for the path of this object. Returns the path this component was registered with. Some subclasses may override this if path structure is dynamic.- Specified by:
getPath
in interfaceLXPath
- Overrides:
getPath
in classLXComponent
- Returns:
- path of this component relative to its parent
-
setInputDispatch
-
onParameterChanged
Description copied from class:LXComponent
Subclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.- Specified by:
onParameterChanged
in interfaceLXParameterListener
- Overrides:
onParameterChanged
in classLXComponent
- Parameters:
p
- Parameter that has a value change
-
getActualFrameRate
public float getActualFrameRate()Gets the active frame rate of the engine when in threaded mode- Returns:
- How many FPS the engine is running
-
getCpuLoad
public float getCpuLoad()Gets a very rough estimate of the CPU load the engine is using before maxing out.- Returns:
- Estimated CPU load
-
setFixedDeltaMs
Utility for when rendering offline videos. Ignore how much real-time has passed between frames and compute animations based upon the given deltaMs- Parameters:
deltaMs
- Fixed deltaMs between rendered frames- Returns:
- this
-
start
public void start()Starts the engine thread. -
stop
public void stop()Stops the engine thread. -
isThreaded
public boolean isThreaded()Returns whether the engine is actively threaded- Returns:
- Whether engine is threaded
-
setThreaded
Sets the engine to threaded or non-threaded mode. Should only be called from the Processing animation thread.- Parameters:
threaded
- Whether engine should run on its own thread- Returns:
- this
-
onP4DidDispose
Utility method to shut down and join the engine thread, only when specifically in P4 mode.- Returns:
- this
-
beforeP4LXDraw
public void beforeP4LXDraw()Utility method for P4LX mode, invoked from the Processing draw thread to give a chance to change the threading state before the draw loop. -
setSpeed
Sets a global speed factor on the core animation engine. This does not impact the tempo object.- Parameters:
speed
- Global speed multiplier- Returns:
- this
-
setPaused
Pause the engine from running- Parameters:
paused
- Whether to pause the engine to pause- Returns:
- this
-
isPaused
public boolean isPaused() -
registerComponent
Register a component with the engine. It will be saved and loaded.- Parameters:
path
- Unique path key for saving and loading componentcomponent
- Component- Returns:
- this
-
addTask
Add a task to be run once on the engine thread.- Parameters:
runnable
- Task to run- Returns:
- this
-
addLoopTask
Add a task to be run on every loop of the engine thread.- Parameters:
loopTask
- Task to run on each engine loop- Returns:
- this
-
removeLoopTask
Remove a task from the list run on every loop invocation- Parameters:
loopTask
- Task to stop running on every loop- Returns:
- this
-
addOutput
Sets the output driver- Parameters:
output
- Output driver, or null for no output- Returns:
- this
-
getModulationEngine
- Specified by:
getModulationEngine
in interfaceLXModulationContainer
-
run
public void run()This is the core run loop of the LXEngine. It can be invoked from various places, such as the EngineThread when running in multi-threaded mode, or from a Processing sketch when in P4LX, or from another application framework. Unless you are writing your own new application framework using LX (this is not recommended), you should never call this method directly. It is only public to make it accessible to these other frameworks. -
copyFrameThreadSafe
This should be used when in threaded mode. It synchronizes on the double-buffer and duplicates the internal copy buffer into the provided buffer.- Parameters:
frame
- Frame buffer to copy into
-
getFrameNonThreadSafe
Non-thread safe accessor of the render buffer. Directly copies from it, which if in multi-threaded mode could happen during modification. Basically, never call this from the non-engine thread.- Parameters:
frame
- Frame buffer to copy into
-
handleOscMessage
Description copied from class:LXComponent
Handles an OSC message sent to this component. By default this method handles registered components and parameters, but subclasses may override this method to handle different types of OSC messages.- Specified by:
handleOscMessage
in interfaceLXOscComponent
- Overrides:
handleOscMessage
in classLXComponent
- Parameters:
message
- Full OSC message objectparts
- The OSC address pattern, broken into an array of partsindex
- Which index into the parts array corresponds to this component's children- Returns:
true
if the OSC message was handled and should be considered consumed,false
otherwise
-
load
Description copied from class:LXComponent
Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.- Specified by:
load
in interfaceLXSerializable
- Overrides:
load
in classLXComponent
- Parameters:
lx
- LX instanceobj
- Object to deserialize
-
dispose
public void dispose()Description copied from class:LXComponent
Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally callsuper.dispose()
at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.- Overrides:
dispose
in classLXComponent
-