Skip to content

Loudness normalization for reference audio (BS.1770-4)#9

Merged
TroyHernandez merged 4 commits into
mainfrom
loudness-norm
Jun 12, 2026
Merged

Loudness normalization for reference audio (BS.1770-4)#9
TroyHernandez merged 4 commits into
mainfrom
loudness-norm

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Ports Python turbo's norm_loudness (pyloudnorm, ITU-R BS.1770-4) to pure base R and closes the one real turbo parity gap found in the 0.1.7 review.

  • R/loudness.R: integrated_loudness() + normalize_loudness() — K-weighting (two RBJ biquads via stats::filter), gated 400 ms blocks at 75 % overlap. No new dependencies.
  • Validation: matches pyloudnorm to 6 decimals on 4 synthetic signals and on jfk.wav; normalization lands on -27.000000 LUFS exactly. Reference values generated in the 0.1.7 container (scripts/save_loudness_ref.py), hardcoded in inst/tinytest/test_loudness.R.
  • create_voice_embedding(norm_loudness=): defaults match Python — TRUE for turbo, FALSE for standard.
  • read_audio() stereo fix: validation surfaced that stereo files silently dropped the right channel; now downmixes by channel mean (librosa parity). Only caller is create_voice_embedding (blast_radius checked).

Full tinytest suite passes (0 failures), document() clean.

…arity)

- New R/loudness.R: integrated_loudness() and normalize_loudness(),
  a pure base-R port of pyloudnorm's K-weighting meter (matches to
  6 decimals on synthetic and real audio).
- create_voice_embedding() gains norm_loudness; defaults follow Python
  (TRUE for turbo, FALSE for standard).
- read_audio() now downmixes stereo by channel mean (librosa parity);
  it previously dropped the right channel silently.
@TroyHernandez TroyHernandez merged commit 9621492 into main Jun 12, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the loudness-norm branch June 12, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant