Converting NAM models
How to load and run .nam models with the nam feature, convert them into the pedal's user AMP format, and choose between the conversion options; also the cab IR conversion. Why the conversions work the way they do, and how they measure on hardware, is in NAM & IR research.
The nam feature
- On by default. It adds
open_stomp::namand the optimised IR conversion (ir::convert_optimised), and pulls inserde_jsonandrustfft. - Models supported: WaveNet models, plain or inside a
SlimmableContainer(NAM 0.5 "classic" and 0.7 files). LSTM and ConvNet models are not supported yet; loading one givesNamError::Unsupported. - Python: always built in, as
open_stomp.namandopen_stomp.ir.
To import straight into a slot, Device::import_nam_file does everything on this page in one call (User AMP and IR slots).
Load and run a model
nam::Model is a pure-Rust port of the parts of NeuralAmpModelerCore (MIT) the converter needs. It matches NeuralAmpModelerCore numerically (tests/nam_inference.rs).
use open_stomp::nam::Model;
let mut model = Model::load("Jcm800.nam")?;
let input = vec![0.0f32; 48_000]; // mono, at the model's rate (normally 48 kHz)
let mut output = vec![0.0f32; input.len()];
model.process(&input, &mut output); // any block length; state carries over
model.reset(); // back to the state after loadingfrom open_stomp import nam
model = nam.Model.load("Jcm800.nam")
out = model.process([0.0] * 48000) # mono, at the model's rate (normally 48 kHz)
model.reset()Model | Meaning |
|---|---|
load(path), from_json_str(s) (Python from_json) | Load a model |
process(input, output) | Run a block; Python returns the output list |
reset() | Clear the history and prewarm with silence, as after loading |
sample_rate() | The rate the model was trained at, if the file says (a property in Python) |
name | Display name from the file's metadata |
architecture | As written in the file: "WaveNet", "SlimmableContainer" |
loudness | The model's loudness in dB from its metadata (written by the NAM trainer) |
How the pedal plays a model
The pedal doesn't run the network. Each user AMP slot holds two filters with the pedal's own fixed saturation between them: G1 → saturation → G2.
- Upload: 2048 floats, 1024 per filter, each response reversed.
- What runs: only the first 512 taps of each filter (
convert::PEDAL_TAPS); the pedal ignores the rest. This was found by re-amping. - Every conversion is an approximation; the options below differ in how they fit G1 and G2. Details: How the pedal plays them.
Conversion options
Measure | Python measure= | How | Time |
|---|---|---|---|
App | "app" | Exactly the official app's algorithm: one 8192-sample run from the model's reset state. Below ~100 Hz its DC blocker's start-up transient dominates, so the low bass follows that transient rather than the model | A few seconds |
Clean | "clean" | The excitation played twice and measured on the steady second period: the model's true small-signal response. Departs from the app on purpose, and uploads only the taps the pedal runs | A few seconds |
Optimised | "optimised" | Clean, then G1 and G2 fitted with a simulation of the pedal until it sounds like the model. The closest to the model on hardware | About a minute (optimised build) |
Optimised is the default for Device::import_nam_file. nam.convert in Python defaults to "app".
use open_stomp::nam::{Model, convert};
use open_stomp::nam::convert::Measure;
let mut model = Model::load("Jcm800.nam")?;
let c = convert(&mut model); // the app's way, our excitation
let c = convert::convert_measured(&mut model, &convert::excitation(), Measure::Optimised);
dev.import_user_amp(2, "Jcm800", &c.data, c.factor)?; // c.data: 2048 floats, c.factor: 1.0from open_stomp import nam
model = nam.Model.load("Jcm800.nam")
c = nam.convert(model) # the app's way, our excitation
c = nam.convert("Jcm800.nam", measure="optimised") # a path works too
dev.import_user_amp(2, "Jcm800", c.data, c.factor)| Rust function | Does |
|---|---|
convert(&mut model) | App with our excitation (below) |
convert::convert_with(&mut model, &bla_x) | App with a given 8192-sample excitation |
convert::convert_measured(&mut model, &bla_x, measure) | Any Measure with a given excitation |
convert::convert_optimised(&mut model, &bla_x, &mut on_step) | Optimised with progress: on_step(done, total) after each step; return false to stop early with the best result so far |
convert::excitation() | Our 8192-sample excitation |
convert::upload_data(&g1_ir, &g2_ir), convert::pedal_irs(&data) | Impulse responses ↔ upload floats, as the pedal runs them |
Python's nam.convert(model_or_path, excitation=None, measure="app", normalise=False) covers all of these and releases the GIL while it runs.
The Converted result
| Field | Meaning |
|---|---|
data | The 2048 floats to upload (G1 then G2) |
factor | The slot-info factor; always 1.0, as in the official app |
levels, levels3 | Fundamental and 3rd-harmonic level per test tone (the 3rd harmonic for the first 83 tones) |
bla_db | The measured linear response 20·log10 H, bins 0–4095 |
g1_gains_db | G1 target gain per tone, in dB |
g1_ir, g2_ir | The 8192-tap minimum-phase responses before truncation (for Optimised, the fitted 512-tap responses as uploaded) |
Constants: convert::N (8192, the FFT length; Python nam.FFT_SIZE), convert::TONE_BINS (the 94 test-tone bins, 58.6 Hz – 14.6 kHz), convert::PEDAL_TAPS (512).
Match the official app exactly
convert reproduces the official app's algorithm, but the app's test signal is a stored table that isn't in this library. With our own test signal (same spectrum, different phases) the result is within the app's own measurement noise: typically 0.1–1.5 dB in 1/3-octave response.
For an exact match, read the test signal from your own installed copy of the official Stomp Manager:
let x = convert::official_excitation("/Applications/Stomp Manager.app")?; // or find_official_excitation()
let c = convert::convert_with(&mut model, &x); // = the official conversion (≤ 0.03 dB)x = nam.official_excitation() # or official_excitation("/path/to/Stomp Manager.app")
c = nam.convert(model, excitation=x)- Opt-in:
import_nam_filenever reads the official app. - Nothing is executed: the table is located in the app's files by a fingerprint (on macOS it is in
imagelib.framework/imagelib). - Search locations (
convert::official_app_locations()):/Applications/Stomp Manager.app,~/Applications/Stomp Manager.app, andStomp Managerunder%ProgramFiles%,%ProgramFiles(x86)%and%LOCALAPPDATA%.
Level
Raw conversions keep the model's own level, which on the pedal is often quiet: it depends on how the model was captured (the official app does the same). Models span about 17 dB raw.
convert::normalise_level(&mut c, &mut model)scales G2 so every model plays atNORMALISED_LEVEL_DB(−32.5 dB), like NAM plugins normalise. Returns the gain applied, in dB.- A pure volume change: only G2, after the pedal's saturation, is scaled, so the tone and the way the amp breaks up stay the same.
- Calibration: normalised imports play at the level of the pedal's built-in bass amps (Ampug SV Bass, Mes 400 Bass) with the same knobs. Un-normalised, two SVT-VR models sat 13–19 dB below those amps; normalised, two that were 6 dB apart raw land within 0.2 dB of each other.
convert::pedal_level_db(&mut model)gives the pedal's output level for a model (pink noise at −18 dBFS in).- Defaults:
Device::import_nam_filenormalises;import_nam_file_withdoesn't;import_nam_file_as(…, normalise)lets you choose. In Python,nam.convert(…, normalise=True)andDevice.import_nam_file(…, normalise=…)(default on).
Tuning the optimiser
nam::optimise is the fit behind Measure::Optimised (Rust only). It simulates the pedal and adjusts G1 and G2 until the simulated output matches the model on a test signal.
use open_stomp::nam::convert::{self, Measure};
use open_stomp::nam::optimise::{self, Options};
let init = convert::convert_measured(&mut model, &convert::excitation(), Measure::Clean);
let options = Options { steps: 600, ..Options::default() };
let fit = optimise::optimise(&mut model, &init.data, &options);
dev.import_user_amp(2, "Jcm800", &fit.data, 1.0)?;Options field | Default | Meaning |
|---|---|---|
steps | 300 | Adam steps; about a minute per 300 steps in an optimised build |
learning_rate | 0.05 | Peak learning rate, reached after warmup steps, then decayed to 0 along a half cosine |
warmup | 10 | Steps to reach the peak learning rate |
smoothness | 1e-3 | Weight of the curve smoothness term |
weighting | Weighting::Octave | Octave: each octave counts about the same (since 0.5.0). Flat: every bin the same, the 0.4 behaviour that gave the low end away |
optimise_with_progress(…, &mut on_step)callson_step(done, total)after each step; returnfalseto stop early.- The result (
Optimised):data(2048 floats),g1_ir/g2_ir,g1_curve/g2_curve,initial_lossandlossper step. optimise::simulate(&data, &input)predicts what the pedal outputs for any upload (mono, 48 kHz, in the re-amp rig's input units).
Why octave weighting matters: NAM and IR conversion.
Cab IRs
The ir module converts WAV impulse responses for the user IR slots. The pedal only plays the first 384 samples (8 ms) of an uploaded IR (ir::PEDAL_IR_TAPS).
ir::Method | Python method= | How |
|---|---|---|
App | "app" | Exactly the official app's conversion, recovered from its code and identical to its uploads: first channel, resampled to 48 kHz like the app, the first 2048 samples reversed and scaled so 398 Hz – 3 kHz is centred on 0 dB |
Optimised | "optimised" | A 384-tap minimum-phase filter fitted to the whole IR's response, at the level the app means to give it. Much closer on the pedal for long IRs, or IRs that start after a delay. Needs feature nam |
Device::import_ir_file uses Optimised; ir::convert and Python's ir.convert default to App.
use open_stomp::ir::{self, Method, Wav};
let wav = Wav::load("My Cab.wav")?;
let c = ir::convert_with(&wav, Method::Optimised); // or ir::convert(&wav), ir::convert_optimised(&wav)
dev.import_user_ir(0, &ir::slot_name("My Cab.wav".as_ref()), &c.data)?;from open_stomp import ir
c = ir.convert("My Cab.wav", method="optimised") # c.data: 2048 floats; c.gain, c.ir
rate, channels = ir.load_wav("My Cab.wav")
dev.import_user_ir(0, "My Cab", c.data)| Rust | Python | Does |
|---|---|---|
Wav::load(path), Wav::parse(bytes), Wav::new(rate, channels) | ir.load_wav(path) → (rate, channels) | Read a WAV (PCM 8–32-bit or float, any channel count) |
wav.to_bytes(bits, float) | ir.save_wav(path, rate, channels, float=False) | Write one |
ir::resample(x, from, to) | ir.resample(samples, src, dst) | Windowed-sinc resampling |
ir::resample_like_app(x, from, to) | ir.resample(…, like_app=True) | The official app's (JUCE) resampler |
ir::app_gain(head) | The app's gain rule | |
ir::slot_name(path) | The name the app gives an import: the file name, first 16 characters | |
ConvertedIr { data, gain, ir } | ConvertedIr | The 2048 floats, the gain applied, the 48 kHz IR before truncation |
Constants: IR_TAPS (2048), PEDAL_IR_TAPS (384; Python PEDAL_TAPS), IR_SAMPLE_RATE (48000; Python SAMPLE_RATE).
How close the conversions are
A bass DI re-amped through the pedal, compared with the original model and IR in software (rms error; lower is better):
| Official app | open-stomp | |
|---|---|---|
| Overall tone (40 Hz–10 kHz) | 9.4 dB | 2.1 dB |
| Low end (40–160 Hz) | 3.0 dB | 3.3 dB |
| Closer to the original | 9% of the recording | 91% |
Cab IRs improve the same way: 2.1–5.2 dB rms from the full IR, against 5.3–16.1 dB for the official upload. See the full results.
Example programs
Run these from a checkout, with --release (the conversions are slow in a debug build).
| Example | Does |
|---|---|
nam_convert -- model.nam [out.bin] | Convert a model; --official [app path] uses the app's excitation, --compare <dump dir> compares with a dump from the vendor converter |
nam_optimise -- model.nam [out.bin] [--steps N] [--normalise] [--flat] | The optimised conversion; --flat uses the pre-0.5 flat weighting |
nam_level -- <dir or .nam files> | Model levels: metadata loudness and measured |
nam_render -- model.nam in.f32 out.f32 | Run raw mono float32 audio (48 kHz) through a model |
nam_check -- model.nam model_io.bin | Compare inference with a NeuralAmpModelerCore recording |
ir_compare -- <dir or .wav files> | Compare the app's and the optimised IR conversion as the pedal plays them |
ir_check -- data.bin a.wav … | Compare uploaded IR data with IR files |
ir_capture_check -- <log> tests/data/ir | Compare the app's IR imports in a capture with the imported files |
ir_test_files -- tests/data/ir | Write the designed test IRs used to pin down the app's IR conversion |
out.bin files hold the 2048 little-endian floats, ready for import_user_amp. Run any of them as cargo run --release --example <name> -- ….
