memlnaut-nisps/schemas/modes/paf_synth.json
monkey-w1n5t0n b16f26e6ab refactor(ml): one runtime-configurable training default (S26)
The operator's call: "there should be one default learning rate and one
default max iterations and they should both be configurable at runtime."

There were SIX copies, not the four the audit described, and they did not
agree:

  nisps/ml/mlp.hpp        no-arg train() hardcoding 1.f / 1000u / 0.001f —
                          and firmware's ONLY training path calls exactly
                          this, so firmware had no runtime knob at all
  wasm-iml.ts             train() and trainAsync() TS default params (x2)
  engine-api.ts           learningRate ?? 1.0, with no maxIterations knob
  vcv/src/iml.hpp         200 / 0.1 / 0.00001 — silently divergent
  external_synth_midi.hpp its own kDefaultLearningRate/kDefaultMaxIterations
  schemas/modes/*.json    x9, identical, read by nobody at runtime

Now: schemas/ml_defaults.json is the single declaration (validated against a
sibling meta-schema, matching the midi_device.schema.json convention), codegen
emits it to C++ and TS in the same run, and MLPCore carries a TrainConfig whose
default member initialisers read the generated constant.
set_train_config()/nisps_ml_set_train_config() make it runtime-overridable on
every target; the explicit-argument train() overload is untouched. min_error
joins the tuple — it was duplicated identically and belongs with the other two.

The per-mode ml block loses default_learning_rate/default_max_iterations.
default_spread stays (genuinely wired on both targets) and input_channels stays
(codegen-time validated, real information for sound_analysis_midi).

VCV BEHAVIOUR CHANGE, deliberate: MEMLNaut.cpp constructs IML positionally and
relies on those defaults, so the module moves to 1000/1.0/0.001 — 5x the max
iterations, 10x the learning rate, and a 100x looser early-stop threshold. The
old values were never justified anywhere; they arrived with fbc68eb alongside
an unrelated module rewrite and no tuning rationale. Firmware and WASM have
shipped 1.0/1000 all along. It is now runtime-settable if this turns out worse.

The generated header lands in nisps/ml/generated/, not nisps/modes/generated/
where the rest of codegen output lives: training hyperparameters are an ML
fact, and nisps/ml sits below nisps/modes, so emitting them there would make
mlp.hpp include upward. The agent that built this flagged the directory-crossing
rather than hiding it; this is the fix. CI's generated-freshness gate learns the
new directory.

Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS (max delta 2.38e-7),
lint clean, manifold typecheck + 17 unit + 33 e2e (which exercise train() and
trainAsync() through a real browser).
2026-07-21 17:20:10 +02:00

62 lines
5.2 KiB
JSON

{
"$schema": "../schema.json",
"_note": "33-param PAF synth. Input channels are 4-DOF analog (joystick X/Y/Z/W). MIDI is hardware-side, not an ML input. Param ranges and curves derived from voicespaces/VoiceSpace1.hpp et al. NN outputs are normalised [0,1]; voice spaces apply per-mapping curves. The schema reports the normalised [0,1] range used to feed voice spaces, and per-param curve hints reflect the dominant scaling pattern in the voice space (e.g. squared = 'square').",
"mode_id": "paf_synth",
"engine_id": "paf_synth",
"ml": {
"input_channels": ["joy_x", "joy_y", "joy_z", "joy_w"],
"input_size": 4,
"hidden_layers": [10, 10, 14],
"output_size": 33,
"default_spread": 0.6
},
"params": [
{ "name": "p00", "label": "Param 00", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "p01", "label": "Param 01", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "paf0_cf", "label": "PAF0 Center Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "paf1_cf", "label": "PAF1 Center Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "p04", "label": "Param 04", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "paf0_bw", "label": "PAF0 Bandwidth", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "paf1_bw", "label": "PAF1 Bandwidth", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "p07", "label": "Param 07", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "paf0_vib", "label": "PAF0 Vibrato Depth","min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "modulation" },
{ "name": "paf1_vib", "label": "PAF1 Vibrato Depth","min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "modulation" },
{ "name": "p10", "label": "Param 10", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "paf0_vfr", "label": "PAF0 Vibrato Rate", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "square", "group": "modulation" },
{ "name": "paf1_vfr", "label": "PAF1 Vibrato Rate", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "square", "group": "modulation" },
{ "name": "p13", "label": "Param 13", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "paf0_shift","label": "PAF0 Shift", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "paf1_shift","label": "PAF1 Shift", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "operators" },
{ "name": "p16", "label": "Param 16", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "dl1mix", "label": "Delay Mix", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "delay" },
{ "name": "p18", "label": "Param 18", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "dlfb", "label": "Delay Feedback", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "delay" },
{ "name": "env_decay", "label": "Env Decay", "min": 0.0, "max": 1.0, "default": 0.3, "curve": "square", "group": "envelope" },
{ "name": "p21", "label": "Param 21", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "p22", "label": "Param 22", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "p23", "label": "Param 23", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "p24", "label": "Param 24", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "p25", "label": "Param 25", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "general" },
{ "name": "shape_gain","label": "Sine Shape Gain", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "shaper" },
{ "name": "shape_asym","label": "Sine Shape Asym", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "shaper" },
{ "name": "shape_mix", "label": "Sine Shape Mix", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "shaper" },
{ "name": "rm_gain", "label": "Ring Mod Gain", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "square", "group": "shaper" },
{ "name": "env_attack","label": "Env Attack", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "envelope" },
{ "name": "env_sustain","label": "Env Sustain", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "envelope" },
{ "name": "env_release","label": "Env Release", "min": 0.0, "max": 1.0, "default": 0.3, "curve": "linear", "group": "envelope" }
],
"voice_spaces": [
"Ellipticacacia",
"Rowantares",
"Neemeda",
"Aquillow",
"Magnetarch",
"Elderstar",
"Ipeleiades"
],
"ui": {
"primary_input": "xy_pad",
"show_voice_space_selector": true,
"show_synth_visualizer": true
}
}