Source:
MoonLiveBuiltins_light.h
moonlive_builtins_light¶
The only place the LED vocabulary lives: the function names, their argument counts, and each inline opcode's meaning.
The core compiler sees only the neutral table and the tags this file hands it, so a different host writes its own registration and leaves core unchanged.
Enumerations¶
| Name | Description |
|---|---|
MotionAxis |
The five fixture roles, in the order [FixtureChannels] declares them. |
| [``] |
MotionAxis¶
The five fixture roles, in the order [FixtureChannels] declares them.
| Value | Description |
|---|---|
Pan |
|
Tilt |
|
Zoom |
|
Rotate |
|
Gobo |
¶
| Value | Description |
|---|---|
kSysWidth |
|
kSysHeight |
|
kSysDepth |
|
kSysX |
|
kSysY |
|
kSysZ |
Typedefs¶
| Return | Name | Description |
|---|---|---|
void(*)(void *ctx, uint16_t x, uint16_t y, uint16_t z) |
AddLightFn |
|
void(*)(void *ctx, const char *name, uint8_t offset, int32_t lo, int32_t hi, CtrlType type) |
AddControlFn |
Where a running defineControls() sends each addControl. |
void(*)(void *ctx, uint8_t amt) |
FadeFn |
Where fade(amt) sends its request. |
void(*)(void *ctx, uint32_t x, uint32_t y, uint32_t z) |
CoordFn |
Where setXYZ sends the coordinate a modifier folded. |
void(*)(void *ctx, uint8_t index, uint8_t r, uint8_t g, uint8_t b) |
PalFn |
Where setPalEntry writes, carrying an index rather than a light. |
void(*)(void *ctx, MotionAxis axis, uint32_t index, uint8_t value) |
MotionFn |
Where the motion setters send their writes. |
bool(*)(void *ctx, bool want) |
TrailSizeFn |
Where trail(1) sends its request for a plane. |
uint16_t(*)(void *ctx, uint16_t count) |
PoolSizeFn |
Where pool(n) sends its sizing request. |
AddLightFn¶
AddControlFn¶
using AddControlFn = void(*)(void *ctx, const char *name, uint8_t offset, int32_t lo, int32_t hi, CtrlType type)
Where a running defineControls() sends each addControl.
FadeFn¶
Where fade(amt) sends its request.
CoordFn¶
Where setXYZ sends the coordinate a modifier folded.
PalFn¶
Where setPalEntry writes, carrying an index rather than a light.
MotionFn¶
Where the motion setters send their writes.
TrailSizeFn¶
Where trail(1) sends its request for a plane.
PoolSizeFn¶
Where pool(n) sends its sizing request.
Functions¶
| Return | Name | Description |
|---|---|---|
uint8_t |
byteArg inline |
Read one argument as a byte, clamped to 0..255. |
uint32_t |
mm_light_paletteR inline |
|
uint32_t |
mm_light_paletteG inline |
|
uint32_t |
mm_light_paletteB inline |
|
uint32_t |
mm_light_smoothstep inline |
|
uint32_t |
mm_light_uvAxis inline |
|
uint32_t |
mm_light_uvX inline |
|
uint32_t |
mm_light_uvY inline |
|
uint32_t |
mm_light_escape inline |
|
uint32_t |
mm_light_polarA inline |
|
uint32_t |
mm_light_polarR inline |
|
uint32_t |
mm_light_fbm inline |
|
uint32_t |
mm_light_warp inline |
|
uint32_t |
mm_light_fbm3 inline |
|
uint32_t |
mm_light_warp3 inline |
|
uint32_t |
mm_light_osc inline |
|
const AddLightSink & |
[addLightSink] inline |
The addLight sink for this thread, or an empty one. |
const AddControlSink & |
[addControlSink] inline |
The control sink for this thread, or an empty one; reading claims no slot. |
const FadeSink & |
[fadeSink] inline |
The fade sink for this thread, or an empty one; reading claims no slot. |
void |
setFadeSink inline |
Point fade() at the layer for one run; nullptr to detach. |
const CoordSink & |
[coordSink] inline |
The coordinate sink for this thread, or an empty one; reading claims no slot. |
void |
setCoordSink inline |
Point setXYZ at the modifier for one run; nullptr to detach. |
const PalSink & |
[palSink] inline |
The palette sink for this thread, or an empty one; reading claims no slot. |
void |
setPalSink inline |
Point setPalEntry at the palette binding for one run; nullptr to detach. |
const MotionSink & |
[motionSink] inline |
The motion sink for this thread, or an empty one; reading claims no slot. |
void |
setMotionSink inline |
Point setPan and setTilt at the effect for one run; nullptr to detach. |
const PoolSizeSink & |
[poolSizeSink] inline |
The pool sizing sink for this thread, or an empty one; reading claims no slot. |
void |
setPoolSizeSink inline |
Point pool(n) at the binding that owns the buffers for one defineControls run; nullptr to detach. |
const PoolSink & |
[poolSink] inline |
The live pool for this thread, or an empty handle; reading claims no slot. |
void |
setPoolSink inline |
Point the per-frame particle builtins at the pool for one run; nullptr to detach. |
const TrailSizeSink & |
[trailSizeSink] inline |
Where trail() asks for its plane, during defineControls only. |
void |
setTrailSizeSink inline |
Install the trail sizer for one defineControls() run; nullptr to detach. |
FlowSink & |
[flowSink] inline |
The trail plane this run may advect and decay, or an empty handle. |
void |
setFlowSink inline |
Hand the flow builtins their planes for one run; a null plane detaches. |
bool |
setAddControlSink inline |
Point addControl at a consumer for one defineControls run; nullptr to detach. |
void |
setAddLightSink inline |
Point addLight at a consumer for one run; nullptr to detach. |
uint32_t |
addControlDecl inline |
The one control declaration: args are name, member offset, min and max. |
uint32_t |
mm_light_addControl inline |
Surface a member as a control within a range; its declared type decides the kind. |
uint32_t |
mm_light_addLight inline |
Place one light at the script's coordinates through this thread's layout sink. |
const draw::Canvas & |
drawCanvas inline |
The canvas the draw builtins render into, valid for one run, or an empty one. |
void |
setDrawCanvas inline |
Point the draw builtins at a canvas for one run; an empty one detaches. |
uint32_t |
mm_light_setPalEntry inline |
Write one of the sixteen active palette entries, as red, green and blue. |
uint32_t |
mm_light_setPalEntryHSV inline |
Write one active palette entry in hue, saturation and value. |
uint32_t |
mm_light_setPaletteColorZ inline |
Color one light in a volume from the active palette. |
uint32_t |
mm_light_setPaletteColor inline |
Color one light from the active palette at a brightness, dropping out-of-range coordinates. |
uint32_t |
mm_light_trail inline |
Ask for the trail plane, or give it up; answers whether one is available. |
uint32_t |
mm_light_fieldRate inline |
Answer true once every n frames, gating the expensive work on a large fixture. |
uint32_t |
mm_light_flowNoise inline |
Advect the trail along a noise field: two decoupled samples, one per axis. |
uint32_t |
mm_light_flowCurl inline |
Advect the trail along a curl field: the same, but divergence-free, so nothing clumps. |
uint32_t |
mm_light_trailDecay inline |
Dim the trail by a half-life in milliseconds, so the tail's length is in seconds not frames. |
uint32_t |
mm_light_emitTrail inline |
Throw light into the trail as a disc, colored from the active palette. |
uint32_t |
mm_light_fade inline |
Dim every light toward black by an amount over 255, the trail primitive. |
uint32_t |
mm_light_setXYZ inline |
Say where this light goes, from a modifier. |
uint32_t |
mm_light_level inline |
The room's overall loudness, or zero on a device with no audio. |
uint32_t |
mm_light_levelSmooth inline |
The room's loudness, smoothed over recent frames. |
uint32_t |
mm_light_band inline |
One of the sixteen log-spaced magnitudes, bass at 0 and treble at 15. |
uint32_t |
mm_light_peakHz inline |
The dominant frequency in the room, in hertz. |
uint32_t |
mm_light_onBeat inline |
True on a transient. |
uint32_t |
motionWrite inline |
The one body all five motion builtins share, differing only in the axis they name. |
uint32_t |
mm_light_set_pan inline |
Aim one head horizontally. |
uint32_t |
mm_light_set_tilt inline |
Aim one head vertically. |
uint32_t |
mm_light_set_zoom inline |
Widen or narrow one head's beam. |
uint32_t |
mm_light_set_rotate inline |
Turn one head's gobo wheel. |
uint32_t |
mm_light_set_gobo inline |
Pick one head's gobo pattern. |
uint32_t |
mm_light_pool inline |
Size this script's particle pool, and report what it got, or zero when the allocation failed. |
uint32_t |
nextEmitSeed inline |
A moving seed for the emitters, since a fixed one throws identical sparks every frame. |
uint32_t |
mm_light_emit inline |
Throw a number of particles from a point, at an angle, speed, life and hue. |
uint32_t |
mm_light_gravity inline |
Pull every live particle down, in sub-pixels per reference frame squared. |
uint32_t |
mm_light_drag inline |
Bleed speed off every live particle, 0 none and 255 nearly all. |
uint32_t |
mm_light_step inline |
Move every live particle by its velocity, the integrator. |
uint32_t |
mm_light_bounce inline |
Reflect every particle off the grid's walls, keeping a fraction of 256 of its speed. |
uint32_t |
mm_light_collide inline |
Make particles bounce off each other, within a contact radius in whole pixels. |
uint32_t |
mm_light_age inline |
Count down every particle's life, freeing the slot of one that reaches zero. |
uint32_t |
mm_light_render inline |
Draw every live particle, dimmed by the life it has left. |
uint32_t |
mm_light_line inline |
Draw a straight segment on the effect's canvas, at depth zero. |
uint32_t |
mm_light_circle inline |
Draw a circle outline of a given stroke width, through [draw::ring], converting the script's whole lights to the drawing layer's sub-pixels. |
void |
writeSysVarSlot inline |
Write one system variable into its arena slot, full width. |
SysVarTable |
lightSysVars inline |
The system variables every light script can read, the grid's dimensions and a light's position. |
SysVarTable |
layoutSysVars inline |
The system variables a layout reads. |
SysVarTable |
effectSysVars inline |
The system variables an effect reads. |
SysVarTable |
modifierSysVars inline |
The system variables a modifier reads. |
uint32_t |
mm_light_smin inline |
Blend two signed distances smoothly, over a smoothing width. |
const BuiltinTable & |
lightBuiltins inline |
The light-domain builtin table the binding injects into the compiler. |
void |
runDefineControls inline |
Run a script's defineControls, so the controls it declares exist. |
byteArg¶
inline
Read one argument as a byte, clamped to 0..255.
mm_light_paletteR¶
inline
mm_light_paletteG¶
inline
mm_light_paletteB¶
inline
mm_light_smoothstep¶
inline
mm_light_uvAxis¶
inline
mm_light_uvX¶
inline
mm_light_uvY¶
inline
mm_light_escape¶
inline
mm_light_polarA¶
inline
mm_light_polarR¶
inline
mm_light_fbm¶
inline
mm_light_warp¶
inline
mm_light_fbm3¶
inline
mm_light_warp3¶
inline
mm_light_osc¶
inline
addLightSink¶
inline
The addLight sink for this thread, or an empty one.
addControlSink¶
inline
The control sink for this thread, or an empty one; reading claims no slot.
fadeSink¶
inline
The fade sink for this thread, or an empty one; reading claims no slot.
setFadeSink¶
inline
Point fade() at the layer for one run; nullptr to detach.
coordSink¶
inline
The coordinate sink for this thread, or an empty one; reading claims no slot.
setCoordSink¶
inline
Point setXYZ at the modifier for one run; nullptr to detach.
palSink¶
inline
The palette sink for this thread, or an empty one; reading claims no slot.
setPalSink¶
inline
Point setPalEntry at the palette binding for one run; nullptr to detach.
motionSink¶
inline
The motion sink for this thread, or an empty one; reading claims no slot.
setMotionSink¶
inline
Point setPan and setTilt at the effect for one run; nullptr to detach.
poolSizeSink¶
inline
The pool sizing sink for this thread, or an empty one; reading claims no slot.
setPoolSizeSink¶
inline
Point pool(n) at the binding that owns the buffers for one defineControls run; nullptr to detach.
poolSink¶
inline
The live pool for this thread, or an empty handle; reading claims no slot.
setPoolSink¶
inline
Point the per-frame particle builtins at the pool for one run; nullptr to detach.
trailSizeSink¶
inline
Where trail() asks for its plane, during defineControls only.
setTrailSizeSink¶
inline
Install the trail sizer for one defineControls() run; nullptr to detach.
flowSink¶
inline
The trail plane this run may advect and decay, or an empty handle.
setFlowSink¶
inline
Hand the flow builtins their planes for one run; a null plane detaches.
setAddControlSink¶
inline
Point addControl at a consumer for one defineControls run; nullptr to detach.
setAddLightSink¶
inline
Point addLight at a consumer for one run; nullptr to detach.
addControlDecl¶
inline
The one control declaration: args are name, member offset, min and max.
mm_light_addControl¶
inline
Surface a member as a control within a range; its declared type decides the kind.
mm_light_addLight¶
inline
Place one light at the script's coordinates through this thread's layout sink.
drawCanvas¶
inline
The canvas the draw builtins render into, valid for one run, or an empty one.
setDrawCanvas¶
inline
Point the draw builtins at a canvas for one run; an empty one detaches.
mm_light_setPalEntry¶
inline
Write one of the sixteen active palette entries, as red, green and blue.
mm_light_setPalEntryHSV¶
inline
Write one active palette entry in hue, saturation and value.
mm_light_setPaletteColorZ¶
inline
Color one light in a volume from the active palette.
mm_light_setPaletteColor¶
inline
Color one light from the active palette at a brightness, dropping out-of-range coordinates.
mm_light_trail¶
inline
Ask for the trail plane, or give it up; answers whether one is available.
mm_light_fieldRate¶
inline
Answer true once every n frames, gating the expensive work on a large fixture.
mm_light_flowNoise¶
inline
Advect the trail along a noise field: two decoupled samples, one per axis.
mm_light_flowCurl¶
inline
Advect the trail along a curl field: the same, but divergence-free, so nothing clumps.
mm_light_trailDecay¶
inline
Dim the trail by a half-life in milliseconds, so the tail's length is in seconds not frames.
mm_light_emitTrail¶
inline
Throw light into the trail as a disc, colored from the active palette.
mm_light_fade¶
inline
Dim every light toward black by an amount over 255, the trail primitive.
mm_light_setXYZ¶
inline
Say where this light goes, from a modifier.
mm_light_level¶
inline
The room's overall loudness, or zero on a device with no audio.
mm_light_levelSmooth¶
inline
The room's loudness, smoothed over recent frames.
mm_light_band¶
inline
One of the sixteen log-spaced magnitudes, bass at 0 and treble at 15.
mm_light_peakHz¶
inline
The dominant frequency in the room, in hertz.
mm_light_onBeat¶
inline
True on a transient.
motionWrite¶
inline
The one body all five motion builtins share, differing only in the axis they name.
mm_light_set_pan¶
inline
Aim one head horizontally.
mm_light_set_tilt¶
inline
Aim one head vertically.
mm_light_set_zoom¶
inline
Widen or narrow one head's beam.
mm_light_set_rotate¶
inline
Turn one head's gobo wheel.
mm_light_set_gobo¶
inline
Pick one head's gobo pattern.
mm_light_pool¶
inline
Size this script's particle pool, and report what it got, or zero when the allocation failed.
nextEmitSeed¶
inline
A moving seed for the emitters, since a fixed one throws identical sparks every frame.
mm_light_emit¶
inline
Throw a number of particles from a point, at an angle, speed, life and hue.
mm_light_gravity¶
inline
Pull every live particle down, in sub-pixels per reference frame squared.
mm_light_drag¶
inline
Bleed speed off every live particle, 0 none and 255 nearly all.
mm_light_step¶
inline
Move every live particle by its velocity, the integrator.
mm_light_bounce¶
inline
Reflect every particle off the grid's walls, keeping a fraction of 256 of its speed.
mm_light_collide¶
inline
Make particles bounce off each other, within a contact radius in whole pixels.
mm_light_age¶
inline
Count down every particle's life, freeing the slot of one that reaches zero.
mm_light_render¶
inline
Draw every live particle, dimmed by the life it has left.
mm_light_line¶
inline
Draw a straight segment on the effect's canvas, at depth zero.
mm_light_circle¶
inline
Draw a circle outline of a given stroke width, through [draw::ring], converting the script's whole lights to the drawing layer's sub-pixels.
writeSysVarSlot¶
inline
Write one system variable into its arena slot, full width.
lightSysVars¶
inline
The system variables every light script can read, the grid's dimensions and a light's position.
layoutSysVars¶
inline
The system variables a layout reads.
effectSysVars¶
inline
The system variables an effect reads.
modifierSysVars¶
inline
The system variables a modifier reads.
mm_light_smin¶
inline
Blend two signed distances smoothly, over a smoothing width.
lightBuiltins¶
inline
The light-domain builtin table the binding injects into the compiler.
runDefineControls¶
inline
inline void runDefineControls(MoonLive & engine, PoolSizeFn sizePool = nullptr, void * poolCtx = nullptr, TrailSizeFn sizeTrail = nullptr, void * trailCtx = nullptr)
Run a script's defineControls, so the controls it declares exist.
Variables¶
| Return | Name | Description |
|---|---|---|
constexpr const char * |
kEntryTick constexpr |
The entry points the light domain calls, looked up by name in the emitted block. |
constexpr const char * |
kEntryDefineControls constexpr |
|
constexpr const char * |
kEntryPlaceLights constexpr |
|
constexpr const char * |
kEntryModify constexpr |
kEntryTick¶
constexpr
The entry points the light domain calls, looked up by name in the emitted block.
kEntryDefineControls¶
constexpr
kEntryPlaceLights¶
constexpr
kEntryModify¶
constexpr
AddControlSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:188Public Attributes¶
AddControlFn fn = nullptr
void * ctx = nullptr
AddLightSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:182The addLight sink for one thread, installed by the binding around each run.
Public Attributes¶
AddLightFn fn = nullptr
void * ctx = nullptr
CoordSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:197Public Attributes¶
CoordFn fn = nullptr
void * ctx = nullptr
FadeSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:193Public Attributes¶
FadeFn fn = nullptr
void * ctx = nullptr
FlowSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:225The trail plane a script advects and decays, and the frame's delta.
Public Attributes¶
uint16_t * a = nullptr
: one of the two planes, three uint16 per light
uint16_t * b = nullptr
: the other; which one holds the trail is front
bool * front = nullptr
: true: a holds the trail; false: b does
const uint32_t * frame = nullptr
: the binding's frame counter, for fieldRate
lengthType w = 0
lengthType h = 0
lengthType d = 0
: the plane's extent
uint32_t dtMs = 0
: milliseconds this frame covered
Public Methods¶
inline uint16_t * live() const
: The plane currently holding the trail.
inline uint16_t * spare() const
: The plane the next advect writes into.
MotionSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:208Public Attributes¶
MotionFn fn = nullptr
void * ctx = nullptr
PalSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:201Public Attributes¶
PalFn fn = nullptr
void * ctx = nullptr
PoolSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:221Where the per-frame particle builtins find the pool.
Public Attributes¶
particles::Pool * pool = nullptr
uint32_t scale =
PoolSizeSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:219Where pool(n) sends its sizing request.
Public Attributes¶
PoolSizeFn fn = nullptr
void * ctx = nullptr
TrailSizeSink¶
src/light/moonlive/MoonLiveBuiltins_light.h:213Where trail(1) sends its request for a plane.
Public Attributes¶
TrailSizeFn fn = nullptr
void * ctx = nullptr
SinkSlot¶
src/light/moonlive/MoonLiveBuiltins_light.h:241Public Attributes¶
std::atomic< uintptr_t > owner {0}
AddLightSink sink
draw::Canvas canvas
AddControlSink controls
: where a defineControls run sends addControl
FadeSink fade
: where fade sends its request
MotionSink motion
: where the motion setters send their writes
CoordSink coord
: where setXYZ sends a folded coordinate
PalSink pal
: where setPalEntry writes
PoolSizeSink poolSize
: where pool(n) sends its sizing request
PoolSink pool
: the live particle pool
FlowSink flow
: the trail planes this run may advect
TrailSizeSink trailSize
: where trail(1) asks for a plane
More info¶
Stroke width¶
A script's numbers arrive as unsigned ABI words and are read back signed, then narrowed to the drawing layer's lengthType. The guard and the narrowing have to read the SAME number, or they disagree above 32767. A width of 40000 passes > 0 as an int32 and arrives at ring as -25536; 65536 arrives as 0, and 65537 as the thinnest line. So the clamp happens before the cast, and an absurd width behaves as the widest a length can hold.