← PROJECTS

SPOTLIGHT AI
× grandMA3

Equation Transfer Architecture — 座標ストリームではなく、数式そのものを転送する。AIが生成した数学関数をMA3のLuaエンジンが自律的に評価し、照明を直接制御する。さらに、照明制御のためのシェーダー言語 .lxs フォーマットを策定。数式を人間可読なテキストで記述し、AST JSONにコンパイルして任意のランタイムで実行する。

Equation Transfer Architecture — Transfer equations, not coordinates. MA3's Lua engine autonomously evaluates AI-generated mathematical functions and directly controls fixtures. Additionally, we created .lxs — a shader-like language for programmable lighting control. Write human-readable expressions, compile to AST JSON, run on any runtime.

v3 · Equation Transfer Architecture · .lxs Format · 6 Plugins · Fully Implemented

01パラダイムシフトParadigm Shift

従来 v2
Legacy v2

座標ストリーム方式

Coordinate Streaming

SPOTLIGHT AIがJavaScriptで数式を60fps評価し、32台×xyz+RGB=192 floatを毎フレームOSC/PSNで送信。MA3は座標を受信してFollowするだけ。

SPOTLIGHT AI evaluates equations in JavaScript at 60fps, streaming 192 floats per frame via OSC/PSN. MA3 simply follows received coordinates.

46 KB/s

常時ストリーム。ネットワーク断 = 照明停止。

Constant stream. Network failure = lighting stops.

新方式 v3
New v3

数式転送方式

Equation Transfer

SPOTLIGHT AIが数式そのもの(AST JSON, 数KB)を1回だけ送信。MA3のLuaエンジンが内部で数式を評価し、フィクスチャを直接制御。

SPOTLIGHT AI transmits the equation itself (AST JSON, a few KB) just once. MA3's Lua engine evaluates internally and controls fixtures directly.

~3 KB / once

単発転送。以後MA3が自律動作。

One-shot transfer. MA3 operates autonomously thereafter.

ネットワーク負荷
Network Load
46 KB/s → ~0
レイテンシ
Latency
ネットワーク遅延 → ゼロ
Network delay → Zero
障害耐性
Fault Tolerance
SPOTLIGHT AI非接続でも動作継続
Runs without SPOTLIGHT AI
ショーファイル統合
Show File
数式 = Cueデータとして保存
Equations saved as cue data
60プリセット合計
All 60 Presets
~120–300 KB
表現力
Expressiveness
数百バイトで無限の動き
Infinite motion from a few hundred bytes

02数式の力 — なぜ数式転送なのかPower of Equations — Why Transfer Math

数式が持つ本質的な優位性

The Fundamental Advantage of Equations

照明制御データには2つの表現がある。「毎フレームの座標値テーブル」と「座標値を生成する関数(数式)」。テーブルは有限だが、関数は無限を記述できる。これが数式転送の本質的な利点。

Lighting control data has two representations: "a table of per-frame coordinate values" and "a function (equation) that generates those coordinates." Tables are finite. Functions describe infinity. This is the essential advantage.

100バイトの数式が、10分間のアニメーション(36,000フレーム × 192 float = 27MB のテーブル)と等価な情報を持つ。 しかも数式は無限の時間軸に対して連続的であり、テーブルは有限の時間範囲でしか意味を持たない。

A 100-byte equation carries the same information as a 10-minute animation table (36,000 frames × 192 floats = 27MB). Moreover, the equation is continuous over infinite time, while the table only has meaning within a finite range.

数式で表現できるパターンの豊かさ

Richness of Patterns Expressible Through Math

三角関数、ノイズ関数、剰余演算のわずかな組み合わせで、人間が直感的に「美しい」と感じる動きのほとんどを記述できる。以下は、ごく短い数式がどれほど多彩なパターンを生むかの例。

With just a handful of trigonometric functions, noise, and modular arithmetic, nearly every movement humans intuitively find beautiful can be described. These examples show how short equations produce remarkably diverse patterns.

螺旋(リサージュ拡張)
Spiral (Lissajous Extension)
x = sin(t×2 + i×0.196) × 3
y = cos(t×1.5 + i×0.392) × 2
z = sin(t×0.8) × cos(i×π) + 1.5
周波数比を変えるだけでリサージュ曲線が螺旋に変化。iの位相オフセットで32台が時間差で追従し、群れのような有機的パターンを形成。
Changing frequency ratios transforms Lissajous curves into spirals. Phase offsets by i create time-staggered following, forming organic flock-like patterns.
~180 bytes AST JSON
パーティクル爆発
Particle Explosion
x = sin(i×2π/32) × t × 0.5
y = cos(i×2π/32) × t × 0.5
z = t×2 − t²×0.3
iで放射方向を均等分割、tで距離を拡大。zに二次関数を入れて放物線。花火のように広がって落ちる。
Index i divides radial direction evenly; t expands distance. Quadratic z creates parabolic arcs — lights expand and fall like fireworks.
~150 bytes AST JSON
呼吸するグリッド
Breathing Grid
row = floor(n/6), col = n%6
x = (col−2.5) × (1+sin(t)×0.3)
y = (row−2.5) × (1+cos(t)×0.3)
32台を6×6グリッドに配置し、sin(t)で間隔を呼吸のように伸縮。シンプルな加算だけでグリッドが生物のように脈動。
32 fixtures in a 6×6 grid, with sin(t) pulsing spacing like breathing. Simple addition makes the grid pulsate like a living organism.
~200 bytes AST JSON
波の干渉(モアレ)
Wave Interference (Moiré)
z = sin(i×0.5 + t×2) × 0.5
  + sin(i×0.7 − t×1.3) × 0.4
  + sin(i×1.1 + t×0.5) × 0.3
異なる周波数の波を重ねるだけで干渉パターンが生まれる。3つのsinの加算で、予測不能かつ美しいうねりが出現。
Overlapping waves at different frequencies create interference. Three sin additions produce unpredictable, beautiful undulations.
~160 bytes AST JSON
ノイズ地形
Noise Terrain
x = noise(i×3.7 + t×0.2) × 5
y = noise(i×5.1 + t×0.15) × 5
z = noise(i×2.3 + t×0.3) × 2
ノイズ関数は「制御されたランダム」を生む。隣接フィクスチャが似た値を持ちながら微妙に異なり、有機的な群れの動き。
Noise functions produce "controlled randomness." Adjacent fixtures share similar but subtly different values, forming organic swarm movement.
~140 bytes AST JSON
カラーオーロラ
Color Aurora
r = sin(t + i×0.1) × 0.5 + 0.5
g = sin(t×0.7 + i×0.2 + 2π/3) × 0.5 + 0.5
b = sin(t×1.3 + i×0.15 + 4π/3) × 0.5 + 0.5
RGB各チャンネルの位相を2π/3ずつずらすことで全スペクトルを滑らかに巡回。iオフセットで32台が虹のグラデーション。
Offsetting RGB channels by 2π/3 cycles through the full spectrum. i offset creates rainbow gradients across 32 fixtures.
~170 bytes AST JSON

数学的構成要素と表現力

Mathematical Building Blocks

構成要素Building Block生成されるパターンGenerated Patterns組み合わせCombos
sin / cos円運動、楕円、リサージュ、波、脈動Circular, elliptical, Lissajous, wave, pulsation
sin + sinビート、干渉縞、モアレ、うねりBeats, interference, moiré, undulation
sin × t成長・減衰、爆発、収束、フェードインGrowth/decay, explosion, convergence, fade
i × offsetウェーブ、追従、群れ、カスケードWave, chase, flock, cascade
floor / modグリッド、ステップ、デジタル分割Grid, step, digital subdivision
noise()有機的揺らぎ、風、水面、炎Organic fluctuation, wind, water, flame
atan2 / polar渦巻き、回転場、トルネードVortex, rotation field, tornado
pow / sqrt非線形加速、イージング、重力感Non-linear acceleration, easing, gravity

これらの要素は自由に入れ子にできる。sin(noise(t))は「揺らぎのある周期」を、noise(sin(t))は「周期的に変調されるランダム」を生む。8つの構成要素の組み合わせは事実上無限のバリエーションを持つ。そしてそのすべてが数百バイトのJSONに収まる。

These elements nest freely. sin(noise(t)) produces "oscillation with organic variation." noise(sin(t)) creates "periodically modulated randomness." Eight building blocks yield effectively infinite variations — all fitting in a few hundred bytes of JSON.

JSONフォーマットの具体的メリット

Concrete Advantages of JSON Format

言語非依存
Language-Agnostic
JavaScript でも Lua でも同一JSONを評価可能
Same JSON evaluable in JS, Lua, or any language
セキュリティ
Security
loadstring不要。任意コード実行リスクゼロ
No loadstring. Zero code execution risk
検証可能
Validatable
ASTノード型・深度・関数名を事前検査
Pre-inspect node types, depth, function names
可搬性
Portability
ファイル保存、ネットワーク送信、QRコード化が容易
Easy to save, transmit, or encode as QR codes
変換容易
Transformable
ASTを操作してspeed/scaleを注入、関数合成が可能
Manipulate AST to inject speed/scale, compose functions
AIとの親和性
AI-Friendly
ClaudeがJSON構造を直接生成・理解可能
Claude generates and comprehends JSON structures natively

データサイズ比較

Data Size Comparison

1分 ストリーム v21min stream v2
2.7 MB
10分 ストリーム v210min stream v2
27 MB
数式1プリセット v31 equation v3
~3 KB
60プリセット全部 v3All 60 presets v3
~180 KB

v2は時間に比例してデータが増大する。v3は時間に依存しない。 数式は「10秒間の動き」も「10時間の動き」も同じバイト数。テーブルは時間が倍になればデータも倍。

v2 data grows linearly with time. v3 is time-independent. An equation describes "10 seconds" and "10 hours" in the same bytes. Tables double when duration doubles.

数式の威力を体験する

Experience the Power of Equations

10種類のパターンをリアルタイムアニメーションで確認。各パラメータをスライダーで操作し、数百バイトの数式がどれほど多彩な動きを生み出すかを体感できます。

Explore 10 patterns with real-time animation. Drag sliders to manipulate parameters and see how a few hundred bytes of math produce infinite variations.

Playground を開く Open Playground

03System Architecture

SPOTLIGHT AI (Node.js) Claude API → Math Function Generator AST Compiler (JS → AST JSON) Animation Engine (WebGL Preview 60fps) Equation Sender (OSC) 60 Presets · AI Generation · Speed/Scale AST JSON OSC WebGL Fallback: PSN / OSC / ArtNet (60Hz stream) grandMA3 Lua Math Engine AST Interpreter · Value Noise · Timer 20-30Hz Plugins 1MathEngine — AST eval + Timer 2EquationSync — JSON receive 3ParamControl — Fader link 4PresetStore — 60 equations 5AuxBridge — Fog/Strobe 6StatusBridge — State → AI → SetFixtureValues() → DMX Output ArtNet AST JSON ~3KB once MA3 state 5Hz MACOneCD × 32 + Fog · Strobe · Ambient

核心の違い: v2ではデータパイプ(太い矢印、60Hz)が中央にあった。v3では「知識の転送」(細い矢印、1回)に変わった。MA3は受信者ではなく、自律的な計算エンジンになる。

The core difference: In v2, a thick 60Hz data pipe sat at the center. In v3, it becomes "knowledge transfer" (thin arrow, once). MA3 shifts from passive receiver to autonomous computation engine.

04AST JSON Specification

変換原理

Conversion Principle

// JavaScript
sin(t * 2.0 + i * 0.196) * 3.0

// AST JSON
["*", ["sin", ["+", ["*", "t", 2.0], ["*", "i", 0.196]]], 3.0]

プリセットJSON完全形

Complete Preset JSON

{
  "version": 1,  "name": "Spiral Galaxy",  "fixtures": 32,
  "equations": {
    "x":     ["*", ["sin", ["+", ["*","t",2.0], ["*","i",0.196]]], 3.0],
    "y":     ["*", ["cos", ["+", ["*","t",1.5], ["*","i",0.392]]], 2.0],
    "z":     ["+", ["*", ["sin",["*","t",0.8]], ["cos",["*","i",0.785]]], 1.5],
    "red":   ["+", ["*", ["sin",["+","t",["*","i",0.1]]], 0.5], 0.5],
    "green": ["+", ["*", ["cos",["+",["*","t",0.7],["*","i",0.2]]], 0.5], 0.5],
    "blue":  ["+", ["*", ["sin",["+",["*","t",1.3],["*","i",0.3]]], 0.5], 0.5]
  },
  "loop": { "start":0, "end":20, "repeat":-1 },
  "defaults": { "speed":1.0, "scale":1.0 }
}

ノード型・変数・関数

Node Types, Variables, Functions

Type形式FormatExample
数値Numbernumber3.14
変数Variable"string""t", "i", "n", "pi"
二項演算Binary Op["op", L, R]["+", "t", 1.0]
単項関数Unary Fn["fn", arg]["sin", "t"]
二項関数Binary Fn["fn", a, b]["pow", "t", 2]

変数: Variables: t (経過秒)(elapsed sec), i (正規化 0-1)(normalized 0-1), n (1-32), pi (π)

sin · cos · tan · asin · acos · atan2 · abs · sqrt · pow · min · max · floor · ceil · fmod · clamp · noise

.lxs — Lighting Expression Shader
AST JSONの上位レイヤーとして、人間が直接読み書きできるシェーダー言語 .lxs を策定した。GPUのフラグメントシェーダーが「各ピクセルに対して実行される関数」であるように、.lxs は「各フィクスチャに対して実行される関数」。GLSLを書いたことがあれば5分で書き始められる構文で、AST JSONにコンパイルされ、MA3 Lua、Node.js、ブラウザなど任意のランタイムで実行される。

.lxs — Lighting Expression Shader
We designed .lxs as a human-readable shader language on top of AST JSON. Just as a GPU fragment shader is "a function executed per pixel," .lxs is "a function executed per fixture." Anyone who has written GLSL can start writing .lxs in 5 minutes. It compiles to AST JSON and runs on any runtime — MA3 Lua, Node.js, or browser.

.lxs フォーマット仕様

.lxs Format Specification

言語構文、組み込み関数、マルチグループ・パターンルーティング、ライブデモ、設計哲学など .lxs の全仕様を詳細に解説。

Complete specification including language syntax, built-in functions, multi-group pattern routing, live demo, and design philosophy.

.lxs Spec を見る View .lxs Spec

05MA3 Lua Math Engine

ASTインタプリタ (loadstring不要)

AST Interpreter (no loadstring)

local ops = {
  ["+"]=function(a,b) return a+b end,
  ["-"]=function(a,b) return a-b end,
  ["*"]=function(a,b) return a*b end,
  ["/"]=function(a,b) return b~=0 and a/b or 0 end,
}
local fns = {
  sin=math.sin, cos=math.cos, abs=math.abs,
  sqrt=math.sqrt, pow=math.pow, noise=noise1d, ...
}
function eval(node)
  if type(node)=="number" then return node end
  if type(node)=="string" then return env[node] or 0 end
  local h = node[1]
  if ops[h] then return ops[h](eval(node[2]),eval(node[3])) end
  if fns[h] then
    local a=eval(node[2])
    if node[3] then return fns[h](a,eval(node[3])) end
    return fns[h](a)
  end
  return 0
end
項目MetricValue
AST平均深度Avg AST depth5–8 nodes
1フレーム合計Per frame total32×6×8 = 1,536 calls
20Hz (50ms)
30Hz (33ms)✓ (深度 ≤ 12)✓ (depth ≤ 12)

06Lua Plugins

01

MathEngine

equation_engine.lua

数式エンジンのコア。ASTインタプリタ+Timer評価ループ。GlobalVarsから数式を読み取り、32台×6chを20-30Hzで評価、SetFixtureValues()で直接制御。

Core engine. AST interpreter + Timer loop. Reads equations from GlobalVars, evaluates 32×6ch at 20-30Hz, controls via SetFixtureValues().

CoreTimerPhase 1
02

EquationSync

equation_sync.lua

SPOTLIGHT AIからのAST JSON受信・パース・ロード。JSONパーサー内蔵。ASTバリデーション(未知関数・深度上限検出)。

Receives AST JSON from SPOTLIGHT AI. Built-in JSON parser. AST validation (unknown functions, depth limits).

OSC InJSONPhase 1
03

ParamControl

param_control.lua

Executor 201:Speed, 202:Scale, 203:AuxをGlobalVarsに書き込み。物理フェーダーでAIパターンを直感的に操作。

Maps Executor faders to GlobalVars. Physical faders for intuitive AI pattern control.

ExecutorPhase 2
04

PresetStore

preset_store.lua

60プリセットのAST JSONをGlobalVarsに格納。SPOTLIGHT AI非接続でも全プリセット再生可能。

Stores 60 preset ASTs in GlobalVars. All presets playable without SPOTLIGHT AI.

StorePhase 2
05

AuxBridge

aux_bridge.lua

数式評価結果から補助機材を自動連動。z平均→フォグ、velocity→ストロボ、彩度→環境照明。

Auto-links auxiliaries from equation results. z-avg→fog, velocity→strobe, saturation→ambient.

DerivedPhase 2
06

StatusBridge

status_bridge.lua

MA3のCue状態・Master値をSPOTLIGHT AIに送信。AIが文脈に即した数式を生成。

Sends MA3 state to SPOTLIGHT AI. AI generates context-aware equations.

OSC OutPhase 3

07Signal Flow & OSC

パスPathProtocol頻度Rate内容ContentSize
AI → MA3OSC1× / switchAST JSON2–5 KB
AI → MA3OSCon demandspeed, scale~20 B
MA3 → AIOSC5–10 HzCue, MasterCue, Master~200 B
MA3 internalLua20–30 Hzeval → fixtures

SPOTLIGHT AI → MA3 (UDP :9000)

/spotlight/equation<s>AST JSON (chunked)
/spotlight/equation/end<s>checksum
/spotlight/preset<i>1–60
/spotlight/speed<f>0.1–3.0
/spotlight/scale<f>0.1–5.0
/spotlight/playPlay
/spotlight/stopStop
/spotlight/generate<s>Prompt → AI

MA3 → SPOTLIGHT AI (UDP :8000) 5–10 Hz

/ma3/playback/cue<i> <s>Cue #, name
/ma3/master/grand<f>0–1
/ma3/master/speed<f>BPM
/ma3/timecode<f>sec

08動作モードOperating Modes

Mode A — 推奨Recommended

数式転送

Equation Transfer

MA3が自律的に数式を評価。ネットワーク障害に堅牢。レイテンシゼロ。ショーファイルに数式が保存。

MA3 autonomously evaluates. Robust to network failure. Zero latency. Saved in show file.

AI →[AST 1×]→ MA3 Lua → Fixtures

Mode B — Fallback

座標ストリーム (v2互換)

Coordinate Stream (v2)

超複雑な数式やLuaエンジン負荷問題時。従来のPSN/OSC 60Hzストリーム。

For ultra-complex equations or Lua load issues. Legacy 60Hz stream.

AI →[60Hz]→ MA3 Follow

Mode C — Hybrid

ハイブリッド

Hybrid

位置は数式転送、色はArtNetで直接制御。

Position via equation, color via ArtNet direct.

AST(pos) + ArtNet(RGB)

09Implementation Phases

Phase 1 — Complete ✓

数式エンジン基盤

Math Engine Foundation

MA3 Lua上でAST数式を20Hzで評価、32台のフィクスチャが数式に従って動作。ASTインタプリタ、Value Noise、JSONパーサー、Timer駆動の全コンポーネントが稼働。

AST equations evaluated at 20Hz in MA3 Lua, 32 fixtures moving per math functions. AST interpreter, value noise, JSON parser, and timer-driven loop all operational.

  • AST Interpreter (Lua)Done
  • Value noiseDone
  • JSON Parser (Lua)Done
  • Timer + SetFixtureValuesDone
  • SPOTLIGHT AI: AST CompilerDone
Phase 2 — Complete ✓

転送・操作・保存

Transfer, Control, Storage

プリセット切替→数式転送→フェーダー操作→60プリセットMA3保存。完全な自律動作を達成。SPOTLIGHT AI非接続でも全プリセット再生可能。

Preset switch→transfer→fader control→60 presets stored. Full autonomous operation achieved. All presets playable without SPOTLIGHT AI connection.

  • Plugin 2: EquationSyncDone
  • equation-sender.jsDone
  • Plugin 3: ParamControlDone
  • Plugin 4: PresetStoreDone
  • Plugin 5: AuxBridgeDone
  • 結合テストIntegration testDone
Phase 3 — Complete ✓

AIコンテクスト + 本番準備

AI Context + Production

MA3オペレータがコンソールのみで全機能を操作。SPOTLIGHT AI非接続でも60プリセット再生可能。.lxsフォーマット策定により、照明パターンのポータブルな記述・共有が実現。

Full console-only operation achieved. 60 presets playable without SPOTLIGHT AI. The .lxs format specification enables portable, shareable lighting pattern descriptions.

  • Plugin 6: StatusBridgeDone
  • AI context extensionDone
  • Mode B fallbackDone
  • Executor / ViewButtonDone
  • 本番リハーサルDress rehearsalDone

10File Structure

grandMA3 Plugins

SPOTLIGHT_AI/ ├── SPOTLIGHT_AI.xml ├── equation_engine.lua ← Plugin 1: Core ├── ast_eval.lua ← AST interpreter ├── noise.lua ← Value noise ├── equation_sync.lua ← Plugin 2: Receive ├── json_parser.lua ← JSON → Lua ├── param_control.lua ← Plugin 3: Faders ├── preset_store.lua ← Plugin 4: Store ├── aux_bridge.lua ← Plugin 5: Fog/Strobe └── status_bridge.lua ← Plugin 6: State

SPOTLIGHT AI 追加・変更SPOTLIGHT AI Changes

objectspat-js/ ├── src/ │ ├── ast-compiler.js ← New: JS→AST │ ├── equation-sender.js ← New: OSC sender │ └── animation-engine.js ← Mod: dual mode ├── public/ │ └── index.html ← Mod: mode toggle └── assets-data/presets-ast/ ← New: 60 AST JSONs

MA3 Executor

201: Speed    (0.1x~3.0x)    301: Preset ▲
202: Scale    (0.1x~5.0x)    302: Preset ▼
203: Aux      (0~1.0)        303: Engine Start/Stop
                              304: Shuffle

11Risks & Mitigation

リスクRisk
影響Impact
対策Mitigation
Lua Timer精度
Timer accuracy
カクつき
Stutter
os.clock() delta time。Timer間隔非依存
Delta time via os.clock(). Timer-independent.
AST深度超過
AST overflow
フレーム落ち
Frame drop
深度上限15。AI側で簡略化
Depth cap 15. Simplified by AI.
loadstring
動的コード不可
No dynamic
AST方式は完全不要
AST needs zero loadstring.
AI クラッシュ
AI crash
新規数式不可
No new eq
60プリセットMA3保存済。完全自律
60 presets in MA3. Fully autonomous.
OSCパケット長
OSC packet limit
数式切断
Truncation
チャンク分割 + チェックサム
Chunked transfer + checksum.
GlobalVars
保存失敗
Save fail
1プリセット=1 GlobalVar。圧縮
1 preset = 1 GlobalVar. Compressed.

12将来の拡張Future Extensions

数式ライブ編集
Live Editing
AST内の定数をフェーダーから動的変更
Modify AST constants from faders live
レイヤー合成
Layer Blend
2つの数式をクロスフェード / 加算合成
Crossfade or add-blend two equations
外部入力連動
External Input
BPM、センサー、音声レベルを変数注入
Inject BPM, sensors, audio as variables
AIライブ生成
Live AI
MA3→プロンプト→Claude→AST→MA3。リアルタイムAI
MA3→prompt→Claude→AST→MA3 in real-time
数式遺伝的進化
Genetic Evolution
ASTを交叉・突然変異で進化(Ralph GA連携)
Crossover/mutate ASTs via Ralph GA
マルチコンソール
Multi-Console
同じAST JSONを複数MA3に同時配信
Broadcast same AST to multiple MA3s

13Resources

.lxs Format

.lxs — Lighting Expression Shader 仕様書

.lxs — Lighting Expression Shader Specification

照明制御のためのシェーダー言語。言語構文、組み込み関数、マルチグループ対応、ライブデモ、設計哲学、MA3実装提案を収録。

A shader-like language for programmable lighting. Includes syntax, built-in functions, multi-group routing, live demo, design philosophy, and MA3 implementation proposal.

.lxs Spec ↗
Interactive

Equation Playground

Equation Playground

10種類のパターンをリアルタイムアニメーションで確認。各パラメータをスライダーで操作し、数式の威力を体感。

Explore 10 patterns with real-time animation. Drag sliders to manipulate parameters and experience the power of equations.

Playground ↗