diff --git a/docs/superpowers/specs/2026-06-28-matrix-color-pattern-design.md b/docs/superpowers/specs/2026-06-28-matrix-color-pattern-design.md new file mode 100644 index 0000000..beee418 --- /dev/null +++ b/docs/superpowers/specs/2026-06-28-matrix-color-pattern-design.md @@ -0,0 +1,131 @@ +# Matrix per-color pattern restructure — design + +Date: 2026-06-28 +Status: approved (brainstorming), pending implementation plan +Scope: `sound_algo/data_only/matrix.scd` + `web_realart/public/control/` +Builds on / restructures: the complete per-instrument editor +(`2026-06-28-matrix-instrument-editor-design.md`), already on main. + +## Goal + +Make each matrix color (1-6) a fully autonomous pattern bundling its own +instrument, 16-step note+velocity sequence, capture effect, and pose binding. The +matrix grid cell selects which color/pattern plays for a voice at each bar. The +per-voice effect (mod) and pose bindings — just built — move to per-color. The +editor modal is reorganized around a color selector + a single per-color pattern +editor. + +## Decisions (from brainstorming) + +- 1 color = 1 pattern = { instrument, sequence, effect, pose }, independent per + color. The grid cell's color is the live selection. +- `effect` (capture mod) and `pose` bindings move from per-voice + (`~matMod[vi]`/`~matPoseBindings[vi]`) to per-color (fields of + `~matColorDefs[vi][color]`). +- Modal is **color-centric**: a color selector (1-6) at the top, then one pattern + editor for the selected color (instrument · variation · this color's 16-step + sequence · effect · pose). +- Backward-compat: legacy `.matrix` files with top-level per-voice `mods`/ + `poseBindings` migrate on load (a voice's mod copied to all 6 colors; each pose + binding routed into its color's pose list). New saves nest mod+pose in colorDefs. + +## Data model + +`~matColorDefs[vi][color]` (an Event) gains two fields beyond the existing +`inst, stretch, octave, amp, cutoff, pan, steps`: +- `mod`: `(source: Sym, target: Sym, depth: Float)` or `nil` (no effect). +- `pose`: an Array of `(poseId: Sym, action: Sym)` (the color is implicit). + +`~matMod` and `~matPoseBindings` (per-voice) are REMOVED. The instrument remains +`spec[\inst] ? ~matInstruments[vi]` (per-color override, else the voice default). + +## Engine (matrix.scd) + +- `~matVariationOverlay` and `~matColorStepPattern` read the mod from `spec[\mod]` + (the color def) instead of `~matMod[vi]`. The mod→key logic (cutoff/pan/amp via + `~matModSourceVal`, neutral cutoff, depth) is unchanged except its source. + Factor the mod-key builder into a helper `~matModPairs.(name, spec, volOf)` so + both the overlay and the stepped pattern share it (DRY — today it is duplicated). +- `~matPoseFire.(poseId)` iterates voices × colors × that color's `pose` list: + on a match, `\trigger` re-sources the voice to that color now; `\gate` toggles + the voice's Pdef. (The binding's color is the color it lives under.) +- `~matSetColorMod.(vi, color, source, target, depth)` sets/clears + `~matColorDefs[vi][color][\mod]` (validate target ∈ `~matModTargets[name]`, + source ∈ `~matModSources`; `\none` clears), re-source, echo. +- `~matSetColorPose.(vi, color, poseId, action)` adds/replaces a pose binding in + that color (dedup by poseId; empty poseId clears), echo. +- Pushes: extend the per-voice editor push so the modal gets each color's mod + + pose. Add `~matColorModPush.(vi, color)` → `/matrix/colormod vi color source + target depth`; `~matColorPosePush.(vi, color)` → `/matrix/colorpose vi color n + *`. `/matrix/colordefs/get vi` triggers colordefs + steps + mod + + pose for all 6 colors. + +## OSC contract + +| address | dir | payload | meaning | +|---|---|---|---| +| `/matrix/colormod` | in/out | vi color source target depth | set/echo a color's effect | +| `/matrix/colorpose` | in | vi color poseId action | set a color's pose binding | +| `/matrix/colorpose` | out | vi color n (poseId,action)* | echo a color's pose list | +| `/matrix/pose` | in | poseId | fire (unchanged) | + +The old `/matrix/mod`, `/matrix/posebind`, `/matrix/mods`, `/matrix/poses` (per-voice) +are removed. `/matrix/instrument`, `/matrix/colordef`, `/matrix/step`, +`/matrix/audition`, `/matrix/colordefs|steps/get` stay. + +## Web (color-centric modal) + +Replace the tabbed modal with a color-selector + per-color pattern editor: +- A row of 6 color buttons (tinted m1-m6); selecting one sets `cdColor`. +- The pattern editor for `cdColor` shows, stacked: + - Instrument `