Skip to content

v0.4.0 — descriptive metadata, cab detection, and a loudness unit correction

Choose a tag to compare

@OpenSauce OpenSauce released this 27 Jul 20:00
· 36 commits to main since this release
97fba1e

Typed access to the rest of a .nam file's metadata block, plus a correction to what loudness has always meant.

⚠️ loudness() is dBFS RMS, not LUFS

This is the item that silently changes behaviour, and it needs no code change to hit you.

Metadata::loudness / NamModel::loudness() were documented as "perceived loudness … in LUFS" in 0.2.0 and 0.3.0. That was wrong. NAM's trainer computes

loudness = 20·log10(sqrt(mean(y²)))

against a standardized input — plain RMS in dBFS, with no K-weighting and no gating. It is not a perceptual measure and not ITU-R BS.1770.

If you built loudness normalization on loudness() believing it was LUFS, you have been applying a wrong gain, and two models with the same loudness but different spectra will not match perceptually. The fix here is documentation only — your code still compiles and still misbehaves. Nothing is deprecated or renamed, so nothing will warn you.

No yank: the number itself was always correct and unchanged, only its description was wrong. But if you consume it, re-read what you do with it.

Added

metadata_typed() now returns the whole descriptive block, not just the three calibration numbers:

name, modeled_by, gear_make, gear_model, gear_type, tone_type, trainer, date (new Date type), gain, and the trainer's raw training blob (left untyped — its shape is trainer- and version-specific).

Metadata::includes_cab() / NamModel::includes_cab() answer whether a capture already contains a speaker cabinet, which decides whether an impulse response after the model would be a second one:

match model.includes_cab() {
    Some(true)  => // cab is baked in — don't add an IR
    Some(false) => // no cab — an IR belongs after this
    None        => // unknown — leave the signal chain alone
}

gear_type is a String, not an enum: NAM's trainer and TONE3000 use overlapping-but-different vocabularies, and TONE3000 has already deprecated values (full-rig, ir) that exist in files on disk, so an enum over either set would reject real files. includes_cab() normalizes case, whitespace and - vs _ across both, and returns None rather than guessing at anything it doesn't recognize.

Note it reports what the file claims. gear_type is author-supplied and captures do mislabel themselves — treat the answer as a default to offer the user, not a fact to reroute audio on silently.

Fixed

Metadata fields are now parsed leniently, one at a time. metadata_typed() converts the block in a single from_value that falls back to Default on error, so previously one malformed entry discarded every other field — including the calibration numbers. Widening from 3 fields to 11 made that blast radius unacceptable; each field now absorbs its own error and yields None.

Breaking

Metadata gains fields and is now #[non_exhaustive], so it can no longer be built with a struct literal:

// no longer compiles
Metadata { loudness: None, input_level_dbu: None, output_level_dbu: None }

Read it from metadata_typed() instead. It was never constructible usefully by hand — it only ever comes out of a parsed file — and #[non_exhaustive] means future metadata fields are additive rather than another breaking bump.

Compatibility

No change to the forward pass. Metadata never reaches inference, so audio output is bit-identical to 0.3.0. Parity and RT-safety contracts are unaffected.

Verified against 233 real .nam files: all parse, none lose their calibration numbers, and the cab-inclusive captures are exactly the ones flagged.