Plugin Selection Toys | !new!

getPipeline() return Array.from(this.activePlugins.values());

function encodePreset(preset) return btoa(JSON.stringify(preset)); plugin selection toys

const echoPlugin = id: "echo-delay", name: "Echo Tunnel", category: "audio", exclusiveGroup: "delay", apply: (ctx) => , ui: knob: ["delayTime (0–1)"] ; Part 3: Selection Manager Logic The core engine that enables/disables plugins and resolves conflicts. 3.1. Basic Manager class PluginSelectionManager constructor() this.activePlugins = new Map(); // id -> plugin instance this.groups = new Map(); // exclusiveGroup -> active id enable(plugin) // 1. check exclusive group if (plugin.exclusiveGroup) const existing = this.groups.get(plugin.exclusiveGroup); if (existing) this.disable(existing); this.groups.set(plugin.exclusiveGroup, plugin.id); getPipeline() return Array

// 2. apply to context in order (order matters!) this.activePlugins.set(plugin.id, plugin); this.reorder(); // sort by category/priority check exclusive group if (plugin

interface ToyPlugin id: string; // unique, e.g., "echo-delay" name: string; // "Crazy Echo" category: "audio" interface ToyContext // shared state across plugins audioBuffer?: AudioBuffer; canvas?: HTMLCanvasElement; physicsWorld?: Matter.World; userParams: Record<string, any>;

reorder() // sort: visual → physics → audio (example) this.activePlugins = new Map([...this.activePlugins.entries()] .sort((a,b) => orderMap[a[1].category] - orderMap[b[1].category]));