Skip to main content

Module convert

Module convert 

Source
Expand description

NAM model → pedal user AMP data: the official app’s converter, reimplemented (docs/05).

The pedal doesn’t run the network. It runs G1 → its own static nonlinearity → G2, two 1024-tap FIR filters fitted to the model:

  1. Best linear approximation: a pink multisine at about −90 dBFS through the model; H = |Y| / |X| per FFT bin, plus a 1/24-octave smoothed copy.
  2. Tone test: a full-scale sine at each of 94 frequencies (58.6 Hz – 14.6 kHz); the level of the fundamental and of the 3rd harmonic at the output.
  3. G1 = smoothed H / max(fundamental, 3rd harmonic) at the tone frequencies, interpolated in log-frequency; G2 = H / G1.
  4. Both become minimum-phase impulse responses; the upload is the first 1024 taps of each, reversed, and a factor of 1.0.

The pedal only runs the first PEDAL_TAPS (512) taps of each uploaded filter (found by re-amping, docs/05): the app’s extra 512 taps per filter are ignored. Measure::App keeps the app’s layout byte for byte; the other modes upload exactly what the pedal runs (upload_data).

Every stage was checked against the vendor code (open-stomp-manager tools/namconv). The one difference is the excitation: the vendor’s 8192-sample multisine is a stored table, so excitation generates our own with the same spectrum (see Converted for how close the results are).

Structs§

Converted
The result of a conversion, with every intermediate stage.

Enums§

Measure
How the small-signal response H is measured.

Constants§

N
FFT length of every measurement (48 kHz → 5.859375 Hz per bin).
NORMALISED_LEVEL_DB
The common output level imports are normalised to (normalise_level): the pedal’s output, in dB re full scale, for pink noise at −18 dBFS into the pedal (the re-amp rig’s units). Calibrated on the pedal so normalised imports play at the level of its built-in bass amps (Ampug SV Bass, Mes 400 Bass) with the same knobs (re-amped, tools/pedalsim/nam_level_rig.py).
PEDAL_TAPS
Impulse-response taps of each uploaded filter that the pedal actually runs. An upload holds 1024 floats per filter, the response reversed (data[1023 − k] is tap k of G1, data[2047 − k] of G2), but the pedal uses only taps 0..511 (data[512..1024], data[1536..2048]) and ignores the rest.
TONE_BINS
Tone-test frequencies as FFT bins (the app’s ToneTest_FftBins): roughly 1/12 octave apart.

Functions§

convert
Convert a model with our excitation (see excitation), the app’s way. Differs from the official app’s result by the app’s own measurement noise (1/3-octave response typically within 0.1–1.5 dB). For an exact match, use convert_with and official_excitation.
convert_measured
Convert with a given excitation and measurement mode. Resets the model first.
convert_optimised
Measure::Optimised with progress: on_step(done, total) after each optimiser step (the clean measurement and the model render before the first take about a fifth of the time). Returning false stops early with the best result so far.
convert_with
Convert a model with a given 8192-sample BLA excitation, the app’s way. Resets the model first.
excitation
Our BLA excitation: the same spectrum as the app’s (amplitude √(1/max(f, 40 Hz)) per bin, overall scale 1e-5, about −90 dBFS peak), with phases from a fixed-seed generator.
find_official_excitation
official_excitation from the first standard install location that has it.
normalise_level
Normalise a conversion’s output level like NAM plugins do, so every import plays at the same level (NORMALISED_LEVEL_DB) whatever level its model was captured at. Only G2 (after the pedal’s saturation) is scaled, so this is a pure volume change: the tone and the way the amp breaks up stay the same. Returns the gain applied, in dB.
official_app_locations
Standard install locations of the official app, for official_excitation.
official_excitation
Read the official app’s BLA excitation from an installed copy of Stomp Manager: a file (macOS imagelib.framework/imagelib) or a directory searched recursively (the .app bundle on macOS, the install folder on Windows). Nothing is executed; the table is located by a fingerprint.
pedal_irs
The two impulse responses the pedal actually runs for 2048 floats of upload data (PEDAL_TAPS taps each; the inverse of upload_data).
pedal_level_db
The pedal’s output level for model with the optimiser’s input/output calibration, in dB, for pink noise at −18 dBFS: what an upload that matches the model plays at (resets the model).
upload_data
Upload data for two impulse responses as the pedal runs them: the first PEDAL_TAPS taps of each, reversed, in the second half of each 1024-float block; the halves the pedal ignores are 0.