feat(manifold): browser-only extra gate-sequence tracks (spare net outputs)
The WASM net is fixed at MLP<32,..,126>; MEMLCelium uses the first 56 outputs, so [56..125] are computed-but-unused. Borrow them as extra RatioSeq tracks — native tracks 0-1 read the real rhythm [0..13] (audio-synced), browser-only tracks 2+ read the spare window [56,63,..] → up to 12 tracks total. Firmware stays at 2; no engine reshape. - cv-backend: rhythmBases track->output-base mapping + setRhythmLayout. - useBackendManager: RHYTHM_LAYOUTS keyed by engine (memlcelium = 2 native, 56 params), builds native+spare bases up to the net width. - Outputs UI helper text; spec updated with the real (non-reshape) mechanism. Caveat (documented): one shared net, so RL feedback on the synth also nudges the extra tracks — true independence needs the separate Rhythm MLP (not yet built).
This commit is contained in:
parent
1461779e23
commit
acb8cb7696
4 changed files with 62 additions and 10 deletions
|
|
@ -104,13 +104,21 @@ vary sequence count.
|
||||||
|
|
||||||
### Browser (Manifold) — dynamic, switchable live
|
### Browser (Manifold) — dynamic, switchable live
|
||||||
|
|
||||||
Same three **plus** a fourth, and with **as many ratio sequences as the user wants**
|
Same three **plus** a fourth, and with **more ratio sequences than the firmware's 2**.
|
||||||
(each gate sequence = its own independent 7-param track; the net reshapes to suit):
|
|
||||||
|
|
||||||
- **Continuous & Rhythm (split nets)** — Continuous MLP + a separate Rhythm MLP.
|
**How extra tracks work (IMPLEMENTED, 2026-06-29).** The browser WASM net is fixed
|
||||||
Browser-only (two MLP heads; hardware uses one). `output_size`: shared net =
|
at `MLP<32,…,126>` — it does **not** reshape per mode. MEMLCelium maps the first
|
||||||
`continuous + 7 × n_gates` (mind the 126-output WASM cap → ~16 gates max shared);
|
56 outputs (14 rhythm + 42 synth); outputs **[56..125] are computed but unused**.
|
||||||
split net = the Rhythm net is sized independently, so it scales further.
|
So the browser borrows them: native tracks 0–1 read the real rhythm at [0..13]
|
||||||
|
(in sync with the audio); browser-only tracks 2+ read the spare window
|
||||||
|
[56, 63, …] — **up to 12 tracks total** ((126−56)/7 = 10 extra). The firmware is
|
||||||
|
untouched (still 2). Caveat: it's ONE shared net, so RL feedback that shapes the
|
||||||
|
synth also nudges the extra tracks — they are not *independently* trained. (Per-
|
||||||
|
engine layout lives in `manifold/src/backends/useBackendManager.ts` `RHYTHM_LAYOUTS`.)
|
||||||
|
|
||||||
|
- **Continuous & Rhythm (split nets)** — Continuous MLP + a separate, independently
|
||||||
|
trained Rhythm MLP. Browser-only, NOT yet built — this is the upgrade that
|
||||||
|
decouples the extra tracks from the synth (two MLP heads; hardware uses one).
|
||||||
|
|
||||||
The browser mode is implied by the Outputs config (§4), not a separate picker:
|
The browser mode is implied by the Outputs config (§4), not a separate picker:
|
||||||
choosing continuous-count > 0 and gate-sequences = 0 ⇒ Continuous-only;
|
choosing continuous-count > 0 and gate-sequences = 0 ⇒ Continuous-only;
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,13 @@ export class UseqCvBackend implements OutputBackend {
|
||||||
private seq = new RatioSeqEngine();
|
private seq = new RatioSeqEngine();
|
||||||
private trackGate = new Uint8Array(MAX_TRACKS);
|
private trackGate = new Uint8Array(MAX_TRACKS);
|
||||||
private trackDone = new Uint8Array(MAX_TRACKS);
|
private trackDone = new Uint8Array(MAX_TRACKS);
|
||||||
|
/**
|
||||||
|
* track → output base index for the 7-param rhythm slice. The native tracks
|
||||||
|
* point at the engine's real rhythm params; browser-only extra tracks borrow
|
||||||
|
* the net's spare outputs (beyond the engine's param count). Empty ⇒ contiguous
|
||||||
|
* `track*7` fallback. Set by the dock from the active engine's layout.
|
||||||
|
*/
|
||||||
|
private rhythmBases: number[] = [];
|
||||||
|
|
||||||
private pendingIdentify: (() => void) | null = null;
|
private pendingIdentify: (() => void) | null = null;
|
||||||
|
|
||||||
|
|
@ -136,6 +143,15 @@ export class UseqCvBackend implements OutputBackend {
|
||||||
this.seq.setBpm(bpm);
|
this.seq.setBpm(bpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the rhythm track → output-base mapping (per active engine). Native tracks
|
||||||
|
* read real rhythm params; browser-only extra tracks read the net's spare
|
||||||
|
* outputs. Pass `[]` to fall back to contiguous `track*7`.
|
||||||
|
*/
|
||||||
|
setRhythmLayout(bases: number[]): void {
|
||||||
|
this.rhythmBases = bases;
|
||||||
|
}
|
||||||
|
|
||||||
/** User-gesture path: pick + open a serial port. Throws if the user cancels. */
|
/** User-gesture path: pick + open a serial port. Throws if the user cancels. */
|
||||||
async connect(): Promise<void> {
|
async connect(): Promise<void> {
|
||||||
if (!this.isAvailable()) {
|
if (!this.isAvailable()) {
|
||||||
|
|
@ -324,7 +340,8 @@ export class UseqCvBackend implements OutputBackend {
|
||||||
private seqGate(track: number, routed: Float32Array): boolean {
|
private seqGate(track: number, routed: Float32Array): boolean {
|
||||||
if (track < 0 || track >= MAX_TRACKS) return false;
|
if (track < 0 || track >= MAX_TRACKS) return false;
|
||||||
if (!this.trackDone[track]) {
|
if (!this.trackDone[track]) {
|
||||||
this.trackGate[track] = this.seq.evalTrack(track, decodeTrack(routed, track * 7)).gate ? 1 : 0;
|
const base = this.rhythmBases.length ? (this.rhythmBases[track] ?? -1) : track * 7;
|
||||||
|
this.trackGate[track] = base >= 0 && this.seq.evalTrack(track, decodeTrack(routed, base)).gate ? 1 : 0;
|
||||||
this.trackDone[track] = 1;
|
this.trackDone[track] = 1;
|
||||||
}
|
}
|
||||||
return this.trackGate[track] === 1;
|
return this.trackGate[track] === 1;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,28 @@ import type { BackendContext, BackendStatus, OutputMapping } from './backend';
|
||||||
import type { BackendId, CvSpec, MidiCcSpec, OscSpec, VcvSpec } from '../dock/output-state';
|
import type { BackendId, CvSpec, MidiCcSpec, OscSpec, VcvSpec } from '../dock/output-state';
|
||||||
import { defaultCvSpec, defaultMidiSpec, defaultOscSpec, defaultVcvSpec } from '../dock/output-state';
|
import { defaultCvSpec, defaultMidiSpec, defaultOscSpec, defaultVcvSpec } from '../dock/output-state';
|
||||||
import { BackendManager } from './manager';
|
import { BackendManager } from './manager';
|
||||||
|
import { modeEngineId } from '../console/model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-engine rhythm layout: how many native RatioSeq tracks the engine has and
|
||||||
|
* its real param count (where the net's spare outputs begin). Browser-only extra
|
||||||
|
* gate-sequence tracks borrow those spare outputs (up to the net width). These
|
||||||
|
* are fixed C++ engine facts (e.g. MEMLCelium: 2 sequences × 7 params at [0..13],
|
||||||
|
* 56 params total), NOT derivable from manifold's UI-param mock.
|
||||||
|
*/
|
||||||
|
const RHYTHM_LAYOUTS: Record<string, { nativeTracks: number; paramCount: number }> = {
|
||||||
|
memlcelium: { nativeTracks: 2, paramCount: 56 }, // also the slp_workshop engine
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Build the track → output-base mapping for an engine (native + spare). */
|
||||||
|
function rhythmBasesFor(engineId: string, netOut: number): number[] {
|
||||||
|
const lay = RHYTHM_LAYOUTS[engineId];
|
||||||
|
if (!lay) return [];
|
||||||
|
const bases: number[] = [];
|
||||||
|
for (let t = 0; t < lay.nativeTracks; t++) bases.push(t * 7); // native rhythm params
|
||||||
|
for (let b = lay.paramCount; b + 7 <= netOut; b += 7) bases.push(b); // browser-only spare tracks
|
||||||
|
return bases;
|
||||||
|
}
|
||||||
|
|
||||||
export interface MidiSettings {
|
export interface MidiSettings {
|
||||||
outputId: string | null;
|
outputId: string | null;
|
||||||
|
|
@ -163,7 +185,11 @@ export function useBackendManager(
|
||||||
const specs: CvSpec[] = params.map((p, i) => (p.cv as CvSpec | undefined) ?? defaultCvSpec(i));
|
const specs: CvSpec[] = params.map((p, i) => (p.cv as CvSpec | undefined) ?? defaultCvSpec(i));
|
||||||
cv.setCvConfig(specs);
|
cv.setCvConfig(specs);
|
||||||
cv.setBpm(bpm);
|
cv.setBpm(bpm);
|
||||||
}, [manager, params, bpm]);
|
// Native rhythm tracks read the engine's real params; browser-only extra
|
||||||
|
// tracks borrow the net's spare outputs (the firmware stays at its native count).
|
||||||
|
const netOut = engine?.architecture.outputSize ?? 126;
|
||||||
|
cv.setRhythmLayout(rhythmBasesFor(modeEngineId(modeId), netOut));
|
||||||
|
}, [manager, params, bpm, modeId, engine]);
|
||||||
|
|
||||||
const cvConnect = () => void manager?.cv()?.connect();
|
const cvConnect = () => void manager?.cv()?.connect();
|
||||||
const cvIdentify = () => manager?.cv()?.identify();
|
const cvIdentify = () => manager?.cv()?.identify();
|
||||||
|
|
|
||||||
|
|
@ -650,8 +650,9 @@ function CvConfig({ ctx }: { ctx: ConsoleCtx }) {
|
||||||
|
|
||||||
<SectionLabel>Per-output channel · gate source</SectionLabel>
|
<SectionLabel>Per-output channel · gate source</SectionLabel>
|
||||||
<p style={{ fontSize: 9, color: 'var(--fg-dim)', margin: 0, lineHeight: 1.6 }}>
|
<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
|
Gate channels run a clock-driven <b>Sequence</b> (RatioSeq track, tempo = app BPM) — tracks 0–1 are the
|
||||||
outputs [track×7…]; or <b>Threshold</b> a continuous output. CV channels carry the mapped value.
|
engine's native rhythm; tracks 2+ are browser-only extras on the net's spare outputs (up to ~12 total). Or
|
||||||
|
<b> Threshold</b> a continuous output. CV channels carry the mapped value.
|
||||||
</p>
|
</p>
|
||||||
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
<div style={{ maxHeight: 320, overflow: 'auto' }}>
|
||||||
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue