Implements the spec's rhythm stream for the uSEQ CV backend, on the existing
slp_workshop/MEMLCelium engine (its outputs [0..13] are the 2 RatioSeq tracks).
- ratio-seq.ts: faithful TS port of the engine's gate generator (decode 7
params/track, ratio_seq pulse test, 4/4 bar clock). Unit-tested (5 tests).
- CV backend: gate channels run as a clock-driven Sequence (RatioSeq track from
the rhythm output slice [track*7..]) or a continuous Threshold; BPM-synced to
the app tempo; one eval per track per tick.
- CvSpec gains gateSource ('sequence'|'threshold') + seqTrack; per-gate UI in
the Outputs panel; bpm threaded through useBackendManager.
Next (spec Build Deltas): MIDI note on/off from gate edges; gate-sequence count
+ shared/separate-net toggle + per-input-channel routing; engine 2nd MLP head.
804 lines
29 KiB
TypeScript
804 lines
29 KiB
TypeScript
/**
|
||
* OutputsBackendConfig — the editable, per-backend specialisation of the Outputs
|
||
* panel (backends-spec §4) plus the named-preset bar (§5).
|
||
*
|
||
* Layout: ONE preset bar (save-as / restore / rename / delete, per-backend
|
||
* namespace) on top, then a per-backend config section:
|
||
* - MIDI → output-port picker, number-of-CCs, per-output CC#/channel/name.
|
||
* - OSC → bridge URL + connect status + send-raw toggle, per-output path/range.
|
||
* - VCV/CV→ bridge URL + connect status + send-raw toggle, per-output polarity
|
||
* (uni 0–10 V / bipolar ±5 V). The browser drives + trains the VCV
|
||
* module over the same Deno bridge.
|
||
* - Synth/Particle/Editor → handled by ModeConfig in Drawers (no extra config here).
|
||
*
|
||
* Everything is editable inline; writes go through the shared MFParam store
|
||
* (ctx.setParam) — never a second data path. The full-depth modal reuses the
|
||
* same sections via BackendAdvanced.
|
||
*/
|
||
import { useEffect, useState } from 'react';
|
||
import type { ConsoleCtx } from '../console/types';
|
||
import type { BackendId, CvChannelId, CvSpec } from './output-state';
|
||
import { CV_CHANNELS, defaultCvSpec, defaultMidiSpec, defaultOscSpec, defaultVcvSpec } from './output-state';
|
||
import {
|
||
applyPreset,
|
||
deletePreset,
|
||
getPreset,
|
||
listPresets,
|
||
renamePreset,
|
||
savePreset,
|
||
type OutputPreset,
|
||
} from '../backends/presets';
|
||
import { MIDI_DEVICES, MIDI_DEVICES_BY_ID, type MidiDeviceParam } from '../midi-devices';
|
||
|
||
function num(s: string, fallback: number): number {
|
||
const v = parseFloat(s);
|
||
return Number.isFinite(v) ? v : fallback;
|
||
}
|
||
|
||
const cellInput: React.CSSProperties = {
|
||
width: '100%',
|
||
background: 'var(--bg-1)',
|
||
border: '1px solid var(--line)',
|
||
borderRadius: 'var(--r-1)',
|
||
color: 'var(--fg)',
|
||
fontFamily: 'var(--font-mono)',
|
||
fontSize: 'var(--fs-xs)',
|
||
padding: '3px 6px',
|
||
boxSizing: 'border-box',
|
||
};
|
||
|
||
const btn = (color: string): React.CSSProperties => ({
|
||
fontSize: 'var(--fs-xs)',
|
||
fontFamily: 'var(--font-mono)',
|
||
padding: '3px 9px',
|
||
cursor: 'pointer',
|
||
borderRadius: 'var(--r-pill)',
|
||
border: `1px solid ${color}`,
|
||
background: 'transparent',
|
||
color,
|
||
});
|
||
|
||
function SectionLabel({ children }: { children: React.ReactNode }) {
|
||
return (
|
||
<div
|
||
style={{
|
||
fontSize: 10,
|
||
color: 'var(--fg-dim)',
|
||
textTransform: 'uppercase',
|
||
letterSpacing: '0.1em',
|
||
marginTop: 'var(--sp-2)',
|
||
}}
|
||
>
|
||
{children}
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function Th({ children }: { children: React.ReactNode }) {
|
||
return (
|
||
<th
|
||
style={{
|
||
textAlign: 'left',
|
||
fontSize: 9,
|
||
textTransform: 'uppercase',
|
||
letterSpacing: '0.06em',
|
||
color: 'var(--fg-dim)',
|
||
padding: '4px 6px',
|
||
borderBottom: '1px solid var(--line)',
|
||
}}
|
||
>
|
||
{children}
|
||
</th>
|
||
);
|
||
}
|
||
|
||
// ---- Named-preset bar (backends-spec §5) -----------------------------------
|
||
|
||
function PresetBar({ ctx, backend }: { ctx: ConsoleCtx; backend: BackendId }) {
|
||
const [presets, setPresets] = useState<OutputPreset[]>([]);
|
||
const [name, setName] = useState('');
|
||
const [selected, setSelected] = useState('');
|
||
|
||
const refresh = () => setPresets(listPresets(backend));
|
||
useEffect(() => {
|
||
refresh();
|
||
setSelected('');
|
||
setName('');
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
}, [backend]);
|
||
|
||
const backendSettings = (): Record<string, unknown> => {
|
||
if (backend === 'midi') return { outputId: ctx.midiOutputId, ccCount: ctx.midiCcCount };
|
||
if (backend === 'osc') return { url: ctx.oscUrl, sendRaw: ctx.oscSendRaw };
|
||
if (backend === 'vcv') return { url: ctx.vcvUrl, sendRaw: ctx.vcvSendRaw };
|
||
return {};
|
||
};
|
||
|
||
const applySettings = (s?: Record<string, unknown>) => {
|
||
if (!s) return;
|
||
if (backend === 'midi') {
|
||
if ('outputId' in s) ctx.setMidiOutputId((s.outputId as string | null) ?? null);
|
||
if ('ccCount' in s) ctx.setMidiCcCount(Number(s.ccCount) || ctx.midiCcCount);
|
||
} else if (backend === 'osc') {
|
||
if ('url' in s) ctx.setOscUrl(String(s.url));
|
||
if ('sendRaw' in s) ctx.setOscSendRaw(Boolean(s.sendRaw));
|
||
} else if (backend === 'vcv') {
|
||
if ('url' in s) ctx.setVcvUrl(String(s.url));
|
||
if ('sendRaw' in s) ctx.setVcvSendRaw(Boolean(s.sendRaw));
|
||
}
|
||
};
|
||
|
||
const doSave = () => {
|
||
const n = name.trim();
|
||
if (!n) return;
|
||
savePreset(backend, n, ctx.params, backendSettings());
|
||
refresh();
|
||
setSelected(n);
|
||
};
|
||
const doRestore = (n: string) => {
|
||
const p = getPreset(backend, n);
|
||
if (!p) return;
|
||
ctx.setParams(applyPreset(ctx.params, p));
|
||
applySettings(p.settings);
|
||
};
|
||
const doDelete = () => {
|
||
if (!selected) return;
|
||
deletePreset(backend, selected);
|
||
refresh();
|
||
setSelected('');
|
||
};
|
||
const doRename = () => {
|
||
const to = name.trim();
|
||
if (!selected || !to) return;
|
||
if (renamePreset(backend, selected, to)) {
|
||
refresh();
|
||
setSelected(to);
|
||
}
|
||
};
|
||
|
||
return (
|
||
<div
|
||
style={{
|
||
display: 'flex',
|
||
flexWrap: 'wrap',
|
||
gap: 6,
|
||
alignItems: 'center',
|
||
padding: '6px 8px',
|
||
background: 'var(--bg-2)',
|
||
border: '1px solid var(--line)',
|
||
borderRadius: 'var(--r-1)',
|
||
}}
|
||
>
|
||
<span style={{ fontSize: 9, color: 'var(--fg-dim)', textTransform: 'uppercase', letterSpacing: '0.06em' }}>
|
||
Presets · {backend}
|
||
</span>
|
||
<input
|
||
style={{ ...cellInput, width: 120, flex: '0 0 auto' }}
|
||
placeholder="preset name"
|
||
value={name}
|
||
onChange={(e) => setName(e.target.value)}
|
||
/>
|
||
<button type="button" style={btn('var(--accent)')} onClick={doSave} disabled={!name.trim()}>
|
||
Save as
|
||
</button>
|
||
<select
|
||
value={selected}
|
||
onChange={(e) => {
|
||
setSelected(e.target.value);
|
||
if (e.target.value) doRestore(e.target.value);
|
||
}}
|
||
style={{ ...cellInput, width: 'auto', flex: '0 0 auto', cursor: 'pointer' }}
|
||
>
|
||
<option value="">restore…</option>
|
||
{presets.map((p) => (
|
||
<option key={p.name} value={p.name}>
|
||
{p.name}
|
||
</option>
|
||
))}
|
||
</select>
|
||
<button type="button" style={btn('var(--fg-mute)')} onClick={doRename} disabled={!selected || !name.trim()}>
|
||
Rename
|
||
</button>
|
||
<button type="button" style={btn('var(--danger)')} onClick={doDelete} disabled={!selected}>
|
||
Delete
|
||
</button>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
// ---- Device template picker (synth-midi-cc templates) ----------------------
|
||
|
||
/**
|
||
* Pick an external synth (e.g. Moog Sub 37), see its parameters BY NAME, tick the
|
||
* ones to control, and "Apply" — this fills the per-output CC table (CC#, channel,
|
||
* name) from the device template and sets the CC count. Pure local state + the
|
||
* existing setParam/setMidiCcCount; the applied result lives in the shared params
|
||
* store, so it is saved/restored by the named-preset bar like any other config.
|
||
*/
|
||
function DeviceTemplatePicker({ ctx }: { ctx: ConsoleCtx }) {
|
||
const [deviceId, setDeviceId] = useState('');
|
||
const [selected, setSelected] = useState<Set<string>>(new Set());
|
||
const device = deviceId ? MIDI_DEVICES_BY_ID[deviceId] : undefined;
|
||
const limit = ctx.params.length; // engine output count caps how many CCs we can drive
|
||
|
||
const pickDevice = (id: string) => {
|
||
setDeviceId(id);
|
||
setSelected(new Set());
|
||
};
|
||
const toggle = (id: string) =>
|
||
setSelected((prev) => {
|
||
const next = new Set(prev);
|
||
if (next.has(id)) next.delete(id);
|
||
else next.add(id);
|
||
return next;
|
||
});
|
||
const selectFirst = (n: number) => {
|
||
if (!device) return;
|
||
setSelected(new Set(device.params.slice(0, n).map((p) => p.id)));
|
||
};
|
||
|
||
const apply = () => {
|
||
if (!device) return;
|
||
const chosen = device.params.filter((p) => selected.has(p.id)).slice(0, limit);
|
||
if (chosen.length === 0) return;
|
||
ctx.setMidiCcCount(chosen.length);
|
||
chosen.forEach((p, i) =>
|
||
ctx.setParam(i, {
|
||
name: p.label,
|
||
midi: { cc: p.cc, channel: device.default_channel, name: p.label, value: 0 },
|
||
}),
|
||
);
|
||
};
|
||
|
||
// Stable, first-seen-order grouping for the checklist.
|
||
const groups: { group: string; params: MidiDeviceParam[] }[] = [];
|
||
if (device) {
|
||
const byGroup = new Map<string, MidiDeviceParam[]>();
|
||
for (const p of device.params) {
|
||
if (!byGroup.has(p.group)) {
|
||
const arr: MidiDeviceParam[] = [];
|
||
byGroup.set(p.group, arr);
|
||
groups.push({ group: p.group, params: arr });
|
||
}
|
||
byGroup.get(p.group)!.push(p);
|
||
}
|
||
}
|
||
|
||
const willApply = device ? Math.min(selected.size, limit) : 0;
|
||
const overflow = selected.size > limit;
|
||
|
||
return (
|
||
<>
|
||
<SectionLabel>Device template</SectionLabel>
|
||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
|
||
<select
|
||
value={deviceId}
|
||
onChange={(e) => pickDevice(e.target.value)}
|
||
style={{ ...cellInput, width: 'auto', cursor: 'pointer' }}
|
||
>
|
||
<option value="">— manual (no template) —</option>
|
||
{MIDI_DEVICES.map((d) => (
|
||
<option key={d.device_id} value={d.device_id}>
|
||
{d.name} · {d.params.length} params
|
||
</option>
|
||
))}
|
||
</select>
|
||
{device && (
|
||
<>
|
||
<button type="button" style={btn('var(--fg-mute)')} onClick={() => selectFirst(Math.min(limit, device.params.length))}>
|
||
Select first {Math.min(limit, device.params.length)}
|
||
</button>
|
||
<button type="button" style={btn('var(--fg-mute)')} onClick={() => setSelected(new Set())}>
|
||
Clear
|
||
</button>
|
||
<button type="button" style={btn('var(--accent)')} onClick={apply} disabled={willApply === 0}>
|
||
Apply {willApply} → outputs
|
||
</button>
|
||
</>
|
||
)}
|
||
</div>
|
||
{device && (
|
||
<>
|
||
<p style={{ fontSize: 9, color: overflow ? 'var(--warn)' : 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
||
{device.manufacturer} · default ch {device.default_channel} · {selected.size} selected
|
||
{overflow ? ` (only the first ${limit} will map — engine has ${limit} outputs)` : ''}. Tick the parameters
|
||
the model should drive, then Apply. You can still tweak CC#/channel below.
|
||
</p>
|
||
<div style={{ maxHeight: 240, overflow: 'auto', border: '1px solid var(--line)', borderRadius: 'var(--r-1)', padding: '4px 6px' }}>
|
||
{groups.map(({ group, params }) => (
|
||
<div key={group} style={{ marginBottom: 4 }}>
|
||
<div style={{ fontSize: 9, color: 'var(--fg-dim)', textTransform: 'uppercase', letterSpacing: '0.06em', margin: '4px 0 2px' }}>
|
||
{group}
|
||
</div>
|
||
{params.map((p) => (
|
||
<label
|
||
key={p.id}
|
||
style={{ display: 'flex', gap: 6, alignItems: 'center', fontSize: 'var(--fs-xs)', padding: '1px 0', cursor: 'pointer' }}
|
||
>
|
||
<input type="checkbox" checked={selected.has(p.id)} onChange={() => toggle(p.id)} />
|
||
<span style={{ flex: 1 }}>{p.label}</span>
|
||
<span style={{ color: 'var(--fg-mute)', fontFamily: 'var(--font-mono)' }}>CC {p.cc}</span>
|
||
</label>
|
||
))}
|
||
</div>
|
||
))}
|
||
</div>
|
||
</>
|
||
)}
|
||
</>
|
||
);
|
||
}
|
||
|
||
// ---- MIDI config (backends-spec §2.3 / §4.1) -------------------------------
|
||
|
||
function MidiConfig({ ctx }: { ctx: ConsoleCtx }) {
|
||
const s = ctx.backendStatus;
|
||
const statusColor =
|
||
s.state === 'ready' ? 'var(--good)' : s.state === 'error' || s.state === 'unavailable' ? 'var(--danger)' : 'var(--warn)';
|
||
return (
|
||
<>
|
||
<SectionLabel>MIDI output</SectionLabel>
|
||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
|
||
<select
|
||
value={ctx.midiOutputId ?? ''}
|
||
onChange={(e) => ctx.setMidiOutputId(e.target.value || null)}
|
||
onFocus={ctx.refreshMidiPorts}
|
||
style={{ ...cellInput, width: 'auto', cursor: 'pointer' }}
|
||
>
|
||
<option value="">— pick output port —</option>
|
||
{ctx.midiPorts.map((p) => (
|
||
<option key={p.id} value={p.id}>
|
||
{p.name}
|
||
</option>
|
||
))}
|
||
</select>
|
||
<label style={{ display: 'flex', gap: 6, alignItems: 'center', fontSize: 'var(--fs-xs)', color: 'var(--fg-dim)' }}>
|
||
CCs
|
||
<input
|
||
type="number"
|
||
min={1}
|
||
max={ctx.params.length}
|
||
value={ctx.midiCcCount}
|
||
onChange={(e) =>
|
||
ctx.setMidiCcCount(Math.max(1, Math.min(ctx.params.length, num(e.target.value, ctx.midiCcCount))))
|
||
}
|
||
style={{ ...cellInput, width: 60 }}
|
||
/>
|
||
</label>
|
||
<span style={{ fontSize: 9, color: statusColor }}>{s.message}</span>
|
||
</div>
|
||
|
||
<DeviceTemplatePicker ctx={ctx} />
|
||
|
||
<SectionLabel>Per-output CC · name · channel</SectionLabel>
|
||
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||
<thead>
|
||
<tr>
|
||
<Th>Name</Th>
|
||
<Th>CC#</Th>
|
||
<Th>Ch</Th>
|
||
<Th>State</Th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{ctx.params.slice(0, ctx.midiCcCount).map((p, i) => {
|
||
const m = p.midi ?? defaultMidiSpec(i);
|
||
return (
|
||
<tr key={i}>
|
||
<td style={{ padding: '3px 6px' }}>
|
||
<input
|
||
style={cellInput}
|
||
value={m.name}
|
||
onChange={(e) => ctx.setParam(i, { midi: { ...m, name: e.target.value } })}
|
||
/>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', width: 70 }}>
|
||
<input
|
||
type="number"
|
||
min={0}
|
||
max={127}
|
||
style={cellInput}
|
||
value={m.cc}
|
||
onChange={(e) =>
|
||
ctx.setParam(i, { midi: { ...m, cc: Math.max(0, Math.min(127, num(e.target.value, m.cc))) } })
|
||
}
|
||
/>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', width: 60 }}>
|
||
<input
|
||
type="number"
|
||
min={1}
|
||
max={16}
|
||
style={cellInput}
|
||
value={m.channel}
|
||
onChange={(e) =>
|
||
ctx.setParam(i, {
|
||
midi: { ...m, channel: Math.max(1, Math.min(16, num(e.target.value, m.channel))) },
|
||
})
|
||
}
|
||
/>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', fontSize: 'var(--fs-xs)', color: 'var(--fg-mute)' }}>
|
||
{p.status}
|
||
{p.muted ? ' · muted' : ''}
|
||
</td>
|
||
</tr>
|
||
);
|
||
})}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|
||
|
||
// ---- OSC config (backends-spec §2.4 / §4.2) --------------------------------
|
||
|
||
function OscConfig({ ctx }: { ctx: ConsoleCtx }) {
|
||
const s = ctx.backendStatus;
|
||
const statusColor = s.state === 'ready' ? 'var(--good)' : s.state === 'connecting' ? 'var(--warn)' : 'var(--danger)';
|
||
const [draftUrl, setDraftUrl] = useState(ctx.oscUrl);
|
||
useEffect(() => setDraftUrl(ctx.oscUrl), [ctx.oscUrl]);
|
||
return (
|
||
<>
|
||
<SectionLabel>OSC bridge</SectionLabel>
|
||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
|
||
<input
|
||
style={{ ...cellInput, width: 200 }}
|
||
value={draftUrl}
|
||
onChange={(e) => setDraftUrl(e.target.value)}
|
||
onBlur={() => ctx.setOscUrl(draftUrl)}
|
||
placeholder="ws://localhost:8765"
|
||
/>
|
||
<button type="button" style={btn('var(--accent)')} onClick={() => ctx.setOscUrl(draftUrl)}>
|
||
Connect
|
||
</button>
|
||
<label style={{ display: 'flex', gap: 6, alignItems: 'center', fontSize: 'var(--fs-xs)', color: 'var(--fg-dim)' }}>
|
||
<input type="checkbox" checked={ctx.oscSendRaw} onChange={(e) => ctx.setOscSendRaw(e.target.checked)} />
|
||
send raw 0..1
|
||
</label>
|
||
<span style={{ fontSize: 9, color: statusColor }}>{s.message}</span>
|
||
</div>
|
||
<p style={{ fontSize: 9, color: 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
||
The Deno OSC bridge process must be running locally (see manifold/osc-bridge). The browser sends over
|
||
WebSocket; the bridge encodes OSC and forwards over UDP.
|
||
</p>
|
||
|
||
<SectionLabel>Per-output address · physical range</SectionLabel>
|
||
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||
<thead>
|
||
<tr>
|
||
<Th>OSC path</Th>
|
||
<Th>range min</Th>
|
||
<Th>range max</Th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{ctx.params.map((p, i) => {
|
||
const o = p.osc ?? defaultOscSpec(p.name);
|
||
return (
|
||
<tr key={i}>
|
||
<td style={{ padding: '3px 6px' }}>
|
||
<input
|
||
style={cellInput}
|
||
value={o.path}
|
||
onChange={(e) => ctx.setParam(i, { osc: { ...o, path: e.target.value } })}
|
||
/>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', width: 90 }}>
|
||
<input
|
||
type="number"
|
||
style={cellInput}
|
||
value={o.rangeMin}
|
||
onChange={(e) => ctx.setParam(i, { osc: { ...o, rangeMin: num(e.target.value, o.rangeMin) } })}
|
||
/>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', width: 90 }}>
|
||
<input
|
||
type="number"
|
||
style={cellInput}
|
||
value={o.rangeMax}
|
||
onChange={(e) => ctx.setParam(i, { osc: { ...o, rangeMax: num(e.target.value, o.rangeMax) } })}
|
||
/>
|
||
</td>
|
||
</tr>
|
||
);
|
||
})}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|
||
|
||
// ---- VCV / CV config (backends-spec §2.6 / §4.3) ---------------------------
|
||
|
||
function VcvConfig({ ctx }: { ctx: ConsoleCtx }) {
|
||
const s = ctx.backendStatus;
|
||
const statusColor = s.state === 'ready' ? 'var(--good)' : s.state === 'connecting' ? 'var(--warn)' : 'var(--danger)';
|
||
const [draftUrl, setDraftUrl] = useState(ctx.vcvUrl);
|
||
useEffect(() => setDraftUrl(ctx.vcvUrl), [ctx.vcvUrl]);
|
||
return (
|
||
<>
|
||
<SectionLabel>VCV bridge</SectionLabel>
|
||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
|
||
<input
|
||
style={{ ...cellInput, width: 200 }}
|
||
value={draftUrl}
|
||
onChange={(e) => setDraftUrl(e.target.value)}
|
||
onBlur={() => ctx.setVcvUrl(draftUrl)}
|
||
placeholder="ws://localhost:8765"
|
||
/>
|
||
<button type="button" style={btn('var(--accent)')} onClick={() => ctx.setVcvUrl(draftUrl)}>
|
||
Connect
|
||
</button>
|
||
<label style={{ display: 'flex', gap: 6, alignItems: 'center', fontSize: 'var(--fs-xs)', color: 'var(--fg-dim)' }}>
|
||
<input type="checkbox" checked={ctx.vcvSendRaw} onChange={(e) => ctx.setVcvSendRaw(e.target.checked)} />
|
||
send raw 0..1
|
||
</label>
|
||
<span style={{ fontSize: 9, color: statusColor }}>{s.message}</span>
|
||
</div>
|
||
<p style={{ fontSize: 9, color: 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
||
The VCV Rack NISPS module AND the Deno OSC bridge (manifold/osc-bridge) must both be running. The browser drives
|
||
the module's inputs and forwards the verdict loop (thumbs up/down, explore-and-place) over the bridge, so the
|
||
module's embedded net trains in lock-step. Default module UDP port 7001.
|
||
</p>
|
||
|
||
<SectionLabel>Per-output polarity</SectionLabel>
|
||
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||
<thead>
|
||
<tr>
|
||
<Th>output</Th>
|
||
<Th>range</Th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{ctx.params.map((p, i) => {
|
||
const v = p.vcv ?? defaultVcvSpec();
|
||
return (
|
||
<tr key={i}>
|
||
<td style={{ padding: '3px 6px', fontSize: 'var(--fs-xs)', color: 'var(--fg-dim)' }}>{p.name}</td>
|
||
<td style={{ padding: '3px 6px', width: 110 }}>
|
||
<button
|
||
type="button"
|
||
onClick={() => ctx.setParam(i, { vcv: { bipolar: !v.bipolar } })}
|
||
style={{
|
||
...btn(v.bipolar ? 'var(--danger)' : 'var(--fg-mute)'),
|
||
width: '100%',
|
||
}}
|
||
>
|
||
{v.bipolar ? '±5 V' : '0–10 V'}
|
||
</button>
|
||
</td>
|
||
</tr>
|
||
);
|
||
})}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|
||
|
||
// ---- uSEQ CV / gate config (backends-spec §2.5; docs/useq-celium) -----------
|
||
|
||
function CvConfig({ ctx }: { ctx: ConsoleCtx }) {
|
||
const s = ctx.backendStatus;
|
||
// Green ONLY when the module has actually talked back (handshake confirmed);
|
||
// amber while waiting, red on error, grey when nothing is connected.
|
||
const dotColor =
|
||
s.state === 'ready'
|
||
? 'var(--good)'
|
||
: s.state === 'connecting'
|
||
? 'var(--warn)'
|
||
: s.state === 'idle'
|
||
? 'var(--fg-mute)'
|
||
: 'var(--danger)';
|
||
const handshakeLabel =
|
||
s.state === 'ready'
|
||
? 'Module handshake OK'
|
||
: s.state === 'idle'
|
||
? 'Not connected'
|
||
: s.message;
|
||
return (
|
||
<>
|
||
<SectionLabel>uSEQ device (USB serial)</SectionLabel>
|
||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>
|
||
<button type="button" style={btn('var(--accent)')} onClick={ctx.cvConnect}>
|
||
Connect device
|
||
</button>
|
||
<button type="button" style={btn('var(--fg-mute)')} onClick={ctx.cvIdentify}>
|
||
Identify (flash LEDs)
|
||
</button>
|
||
<button type="button" style={btn('var(--danger)')} onClick={ctx.cvDisconnect}>
|
||
Disconnect
|
||
</button>
|
||
</div>
|
||
<div
|
||
style={{
|
||
display: 'flex',
|
||
alignItems: 'center',
|
||
gap: 7,
|
||
padding: '4px 8px',
|
||
background: 'var(--bg-2)',
|
||
border: '1px solid var(--line)',
|
||
borderRadius: 'var(--r-1)',
|
||
}}
|
||
title={s.message}
|
||
>
|
||
<span
|
||
style={{
|
||
width: 10,
|
||
height: 10,
|
||
borderRadius: '50%',
|
||
flex: '0 0 auto',
|
||
background: dotColor,
|
||
boxShadow: s.state === 'ready' ? `0 0 6px ${dotColor}` : 'none',
|
||
}}
|
||
/>
|
||
<span style={{ fontSize: 'var(--fs-xs)', fontFamily: 'var(--font-mono)', color: dotColor }}>
|
||
{handshakeLabel}
|
||
</span>
|
||
</div>
|
||
<p style={{ fontSize: 9, color: 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
||
Flash the uSEQ main + expander with <code>firmware/useq-celium</code>, connect over USB, then assign each
|
||
model output to a CV jack or gate. 11 CV (3 main + 8 expander) + 3 gates, streamed at 100 Hz.
|
||
</p>
|
||
|
||
<SectionLabel>Per-output channel · gate source</SectionLabel>
|
||
<p style={{ fontSize: 9, color: 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
||
Gate channels run a clock-driven <b>Sequence</b> (RatioSeq, tempo = app BPM) whose 7 params come from rhythm
|
||
outputs [track×7…]; or <b>Threshold</b> a continuous output. CV channels carry the mapped value.
|
||
</p>
|
||
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||
<thead>
|
||
<tr>
|
||
<Th>Output</Th>
|
||
<Th>uSEQ channel</Th>
|
||
<Th>Gate source</Th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{ctx.params.map((p, i) => {
|
||
const c = (p.cv as CvSpec | undefined) ?? defaultCvSpec(i);
|
||
const isGate = c.channel.startsWith('gate');
|
||
return (
|
||
<tr key={i}>
|
||
<td style={{ padding: '3px 6px', fontSize: 'var(--fs-xs)', color: 'var(--fg-dim)' }}>{p.name}</td>
|
||
<td style={{ padding: '3px 6px', width: 150 }}>
|
||
<select
|
||
value={c.channel}
|
||
onChange={(e) => ctx.setParam(i, { cv: { ...c, channel: e.target.value as CvChannelId } })}
|
||
style={{ ...cellInput, cursor: 'pointer' }}
|
||
>
|
||
<option value="none">— none —</option>
|
||
{CV_CHANNELS.map((ch) => (
|
||
<option key={ch.id} value={ch.id}>
|
||
{ch.label}
|
||
</option>
|
||
))}
|
||
</select>
|
||
</td>
|
||
<td style={{ padding: '3px 6px', width: 200 }}>
|
||
{isGate ? (
|
||
<div style={{ display: 'flex', gap: 4, alignItems: 'center' }}>
|
||
<select
|
||
value={c.gateSource}
|
||
onChange={(e) =>
|
||
ctx.setParam(i, { cv: { ...c, gateSource: e.target.value as 'sequence' | 'threshold' } })
|
||
}
|
||
style={{ ...cellInput, width: 'auto', cursor: 'pointer' }}
|
||
>
|
||
<option value="sequence">Sequence</option>
|
||
<option value="threshold">Threshold</option>
|
||
</select>
|
||
{c.gateSource === 'sequence' ? (
|
||
<label style={{ display: 'flex', gap: 3, alignItems: 'center', fontSize: 9, color: 'var(--fg-dim)' }}>
|
||
trk
|
||
<input
|
||
type="number"
|
||
min={0}
|
||
max={15}
|
||
style={{ ...cellInput, width: 46 }}
|
||
value={c.seqTrack}
|
||
onChange={(e) =>
|
||
ctx.setParam(i, {
|
||
cv: { ...c, seqTrack: Math.max(0, Math.min(15, num(e.target.value, c.seqTrack) | 0)) },
|
||
})
|
||
}
|
||
/>
|
||
</label>
|
||
) : (
|
||
<label style={{ display: 'flex', gap: 3, alignItems: 'center', fontSize: 9, color: 'var(--fg-dim)' }}>
|
||
≥
|
||
<input
|
||
type="number"
|
||
min={0}
|
||
max={1}
|
||
step={0.05}
|
||
style={{ ...cellInput, width: 56 }}
|
||
value={c.gateThreshold}
|
||
onChange={(e) =>
|
||
ctx.setParam(i, {
|
||
cv: { ...c, gateThreshold: Math.max(0, Math.min(1, num(e.target.value, c.gateThreshold))) },
|
||
})
|
||
}
|
||
/>
|
||
</label>
|
||
)}
|
||
</div>
|
||
) : (
|
||
<span style={{ fontSize: 'var(--fs-xs)', color: 'var(--fg-mute)' }}>— CV —</span>
|
||
)}
|
||
</td>
|
||
</tr>
|
||
);
|
||
})}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|
||
|
||
// ---- Public entry ----------------------------------------------------------
|
||
|
||
export interface OutputsBackendConfigProps {
|
||
ctx: ConsoleCtx;
|
||
backend: BackendId;
|
||
}
|
||
|
||
/** The specialised, editable per-backend config + preset bar for the Outputs panel. */
|
||
export function OutputsBackendConfig({ ctx, backend }: OutputsBackendConfigProps) {
|
||
// MIDI / OSC / VCV / CV carry a config + preset surface here; synth/particle/editor
|
||
// config is rendered by ModeConfig in Drawers. The full-depth BackendAdvanced
|
||
// modal reuses the same per-channel sections.
|
||
if (backend !== 'midi' && backend !== 'osc' && backend !== 'vcv' && backend !== 'cvgate') return null;
|
||
return (
|
||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||
<PresetBar ctx={ctx} backend={backend} />
|
||
{backend === 'midi' ? (
|
||
<MidiConfig ctx={ctx} />
|
||
) : backend === 'osc' ? (
|
||
<OscConfig ctx={ctx} />
|
||
) : backend === 'vcv' ? (
|
||
<VcvConfig ctx={ctx} />
|
||
) : (
|
||
<CvConfig ctx={ctx} />
|
||
)}
|
||
</div>
|
||
);
|
||
}
|
||
|
||
export { PresetBar as OutputPresetBar };
|
||
|
||
/** Tiny status pill for the Outputs drawer header. */
|
||
export function BackendStatusChip({ ctx }: { ctx: ConsoleCtx }) {
|
||
const s = ctx.backendStatus;
|
||
if (s.state === 'idle') return null;
|
||
const color =
|
||
s.state === 'ready'
|
||
? 'var(--good)'
|
||
: s.state === 'error' || s.state === 'unavailable'
|
||
? 'var(--danger)'
|
||
: 'var(--warn)';
|
||
return (
|
||
<span
|
||
style={{
|
||
fontSize: 9,
|
||
fontFamily: 'var(--font-mono)',
|
||
color,
|
||
border: `1px solid ${color}`,
|
||
borderRadius: 'var(--r-pill)',
|
||
padding: '2px 8px',
|
||
}}
|
||
title={s.message}
|
||
>
|
||
{s.message}
|
||
</span>
|
||
);
|
||
}
|