memlnaut-nisps/schemas/modes/elysiamorf.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

61 lines
6.1 KiB
JSON

{
"$schema": "../schema.json",
"_note": "8-track FM/CC sequencer that emits MIDI CCs. Each track exposes 5 NN-controlled params (carrier freq, mod freq, mod index, phasor mul, phase offset). The firmware class is templated to NPARAMS=56 but only 40 are consumed in ProcessParams (fbLevel is hard-zero, comment in code); the schema follows actual usage at 40. CC numbers: {1,2,3,4,5,9,11,12}. No voice spaces.",
"mode_id": "elysiamorf",
"engine_id": "elysiamorf",
"ml": {
"input_channels": ["joy_x", "joy_y", "joy_z", "joy_w"],
"input_size": 4,
"hidden_layers": [10, 14, 18],
"output_size": 40,
"default_spread": 0.6
},
"params": [
{ "name": "fm0_carrier", "label": "FM0 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm0" },
{ "name": "fm0_mod_freq", "label": "FM0 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm0" },
{ "name": "fm0_mod_index", "label": "FM0 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm0" },
{ "name": "fm0_phasor_mul", "label": "FM0 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm0" },
{ "name": "fm0_phase_off", "label": "FM0 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm0" },
{ "name": "fm1_carrier", "label": "FM1 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm1" },
{ "name": "fm1_mod_freq", "label": "FM1 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm1" },
{ "name": "fm1_mod_index", "label": "FM1 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm1" },
{ "name": "fm1_phasor_mul", "label": "FM1 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm1" },
{ "name": "fm1_phase_off", "label": "FM1 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm1" },
{ "name": "fm2_carrier", "label": "FM2 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm2" },
{ "name": "fm2_mod_freq", "label": "FM2 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm2" },
{ "name": "fm2_mod_index", "label": "FM2 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm2" },
{ "name": "fm2_phasor_mul", "label": "FM2 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm2" },
{ "name": "fm2_phase_off", "label": "FM2 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm2" },
{ "name": "fm3_carrier", "label": "FM3 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm3" },
{ "name": "fm3_mod_freq", "label": "FM3 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm3" },
{ "name": "fm3_mod_index", "label": "FM3 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm3" },
{ "name": "fm3_phasor_mul", "label": "FM3 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm3" },
{ "name": "fm3_phase_off", "label": "FM3 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm3" },
{ "name": "fm4_carrier", "label": "FM4 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm4" },
{ "name": "fm4_mod_freq", "label": "FM4 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm4" },
{ "name": "fm4_mod_index", "label": "FM4 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm4" },
{ "name": "fm4_phasor_mul", "label": "FM4 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm4" },
{ "name": "fm4_phase_off", "label": "FM4 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm4" },
{ "name": "fm5_carrier", "label": "FM5 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm5" },
{ "name": "fm5_mod_freq", "label": "FM5 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm5" },
{ "name": "fm5_mod_index", "label": "FM5 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm5" },
{ "name": "fm5_phasor_mul", "label": "FM5 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm5" },
{ "name": "fm5_phase_off", "label": "FM5 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm5" },
{ "name": "fm6_carrier", "label": "FM6 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm6" },
{ "name": "fm6_mod_freq", "label": "FM6 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm6" },
{ "name": "fm6_mod_index", "label": "FM6 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm6" },
{ "name": "fm6_phasor_mul", "label": "FM6 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm6" },
{ "name": "fm6_phase_off", "label": "FM6 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm6" },
{ "name": "fm7_carrier", "label": "FM7 Carrier", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm7" },
{ "name": "fm7_mod_freq", "label": "FM7 Mod Freq", "min": 0.0, "max": 1.0, "default": 0.5, "curve": "linear", "group": "fm7" },
{ "name": "fm7_mod_index", "label": "FM7 Mod Index", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm7" },
{ "name": "fm7_phasor_mul", "label": "FM7 Phasor Mul", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm7" },
{ "name": "fm7_phase_off", "label": "FM7 Phase Off", "min": 0.0, "max": 1.0, "default": 0.0, "curve": "linear", "group": "fm7" }
],
"voice_spaces": [],
"ui": {
"primary_input": "xy_pad",
"show_voice_space_selector": false,
"show_synth_visualizer": false
}
}