FX suite (wauvio/fx)
Loudness and mastering
See it in action: Measure and set loudness · Mixing: inserts, buses, sends, sidechain, mastering
Loudness measurement (loudness.hpp)
measure_loudness(buf, sr) implements ITU-R BS.1770 / EBU R128-style metering with K-weighting (high shelf +4 dB at 1.68 kHz, then 38 Hz RLB high-pass) and returns LoudnessReport:
| Field | Meaning |
|---|---|
valid | False if shorter than one 400 ms block or fully gated out |
integrated_lufs | Gated programme loudness |
momentary_max_lufs | Loudest 400 ms |
short_term_max_lufs | Loudest 3 s |
loudness_range_lu | LRA (10th–95th percentile of gated short-term values) |
sample_peak_db | dBFS |
true_peak_db | dBTP, 4× oversampled |
normalize_loudness(buf, sr, target_lufs, ceiling_dbtp = −1, limit = true) applies gain to reach the target; if the true peak would exceed the ceiling it uses a lookahead limiter (limit = true) or reduces the gain (limit = false). Length is unchanged; the post-processing report is returned.
Mastering (master.hpp)
MasterSettings: preset (MasterPreset { Clean, Warm, Club, Loud, Gentle, LoFi }), target_lufs −14, ceiling_dbtp −1, glue 1 (bus compression amount), saturation 1, width 1, tilt_db 0, bass_mono true. MasterSettings::for_preset(p) sets the preset's target:
| Preset | Target LUFS | Character (from build_master_chain) |
|---|---|---|
| Clean | −14 | 22 Hz high-pass, glue compressor, imager |
| Warm | −14 | +1.5 dB low shelf, −1 dB high shelf, tape saturation |
| Club | −9 | Bass lift, presence and air, soft saturation, multiband compression, width 1.12 |
| Loud | −8 | Similar to Club with heavier multiband and drive |
| Gentle | −16 | Light air shelf, lower compression ratio |
| LoFi | −16 | 60 Hz high-pass, 9.5 kHz low-pass, tape saturation, width 0.85, no bass-mono |
build_master_chain(settings)returns the chain up to (not including) the loudness limiter: EQ → optional saturator → optional multiband compressor → glue compressor (RMS detector, 90 Hz detector high-pass) → stereo imager (mono below 120 Hz whenbass_mono).master(buf, sr, settings)masters in place to the target and returnsMasterReport(before,after,gain_db,limiter_reduction_db,target_reachedwithin 0.5 LU,iterations).master_for_genre(name)returns starting settings by genre name, ignoring case, spaces and punctuation ("Drum & Bass","drum_and_bass"and"dnb"all work); unknown names yield Clean at −14 LUFS. Targets: classical/ambient −18 (Gentle, reduced glue), jazz/bossa nova −16, blues −15, reggae −14, funk −13, chiptune −12 (Clean), rock −11, touhou −10, metal −9, house/trance −9, techno/dubstep/drum and bass −8 (Club), hardcore/speedcore −7 (Loud).
Full API listing
wauvio/fx/mastering/loudness.hpp
wauvio::fx::struct LoudnessReport
struct LoudnessReport
bool valid = false; ///< false if the audio is shorter than one 400 ms block or entirely gated out
double integrated_lufs = -120.0; ///< gated programme loudness
double momentary_max_lufs = -120.0;///< loudest 400 ms
double short_term_max_lufs = -120.0;///< loudest 3 s
double loudness_range_lu = 0.0; ///< LRA (10th..95th percentile of gated short-term values)
double sample_peak_db = -120.0; ///< dBFS
double true_peak_db = -120.0; ///< dBTP (4x oversampled)
wauvio::fx::class KWeighting
/// K-weighting filter (BS.1770): high-shelf (+4 dB @ 1.68 kHz) then RLB high-pass (38 Hz).
/// Coefficients are derived for any sample rate (same method as libebur128).
class KWeighting
public:
void prepare(double sr)
float tick(float x) noexcept { return s2_.tick(s1_.tick(x)); }
inline LoudnessReport measure_loudness(const StereoBuffer& buf, int sr = 0)
/// Bring `buf` to `target_lufs` (integrated). If the true peak would exceed `ceiling_dbtp`
/// a lookahead limiter is used (limit = true) or the gain is reduced to fit (limit = false).
/// The buffer keeps its length. Returns the loudness measured after processing.
inline LoudnessReport normalize_loudness(StereoBuffer& buf, int sr, double target_lufs,
double ceiling_dbtp = -1.0, bool limit = true)
wauvio/fx/mastering/master.hpp
wauvio::fx::enum class MasterPreset
enum class MasterPreset { Clean, Warm, Club, Loud, Gentle, LoFi };
wauvio::fx::struct MasterSettings
struct MasterSettings
MasterPreset preset = MasterPreset::Clean;
double target_lufs = -14.0; ///< integrated loudness to reach
double ceiling_dbtp = -1.0; ///< true-peak ceiling
double glue = 1.0; ///< 0 = no bus compression .. 1 = preset amount .. 2 = twice as much
double saturation = 1.0; ///< 0 = off .. 1 = preset amount .. 2 = more
double width = 1.0; ///< multiplies the preset's stereo width
double tilt_db = 0.0; ///< + = brighter, - = darker (shelves around 300 Hz / 4 kHz)
bool bass_mono = true; ///< keep the lows centred (mono below ~120 Hz)
/// Preset defaults, including a sensible loudness target for the style.
static MasterSettings for_preset(MasterPreset p)
wauvio::fx::struct MasterReport
struct MasterReport
LoudnessReport before, after;
double gain_db = 0.0; ///< input gain pushed into the limiter
double limiter_reduction_db = 0.0; ///< deepest limiter gain reduction
bool target_reached = false; ///< within 0.5 LU of the target
int iterations = 0;
/// Everything up to (not including) the loudness limiter.
inline Chain build_master_chain(const MasterSettings& s)
/// Master `buf` in place to the loudness target (buffer length is unchanged).
inline MasterReport master(StereoBuffer& buf, int sr, const MasterSettings& s)
/// Starting-point mastering for a genre name (case-, space- and punctuation-insensitive:
/// "Drum & Bass", "drum_and_bass", "dnb" all work). Unknown names -> Clean at -14 LUFS.
inline MasterSettings master_for_genre(const std::string& genre)