R128Net

R128Net brings EBU R128 and ITU-R BS.1770 loudness measurement to .NET, faster than the original C.
It is verified against the original and performs no managed allocation.

Try it in your browser. Nothing to install, nothing uploaded.


Install

dotnet add package R128Net

Use

This program feeds 20 seconds of a stereo 1 kHz sine at -23 dBFS to a meter in blocks of 100 ms, then reads the integrated loudness, the loudness range and the true peak. It prints -23.0 LUFS, 0.0 LU and -23.0 dBTP.

using R128Net;

const int SampleRate = 48000;
const int BlockFrames = SampleRate / 10;

using LoudnessMeter meter = new(channels: 2, SampleRate,
    LoudnessModes.Integrated | LoudnessModes.LoudnessRange | LoudnessModes.TruePeak);

float[] block = new float[2 * BlockFrames];
for (int n = 0; n < 200; ++n)
{
    for (int i = 0; i < BlockFrames; ++i)
    {
        float value = (float)(0.0708 * Math.Sin(2.0 * Math.PI * 1000.0 * ((n * BlockFrames) + i) / SampleRate));
        block[2 * i] = value;
        block[(2 * i) + 1] = value;
    }

    meter.AddFrames(block);
}

Console.WriteLine($"Integrated loudness: {meter.IntegratedLoudness:F1} LUFS");
Console.WriteLine($"Loudness range: {meter.LoudnessRange:F1} LU");
Console.WriteLine($"True peak: {20.0 * Math.Log10(meter.GetTruePeak(0)):F1} dBTP");

What it does

Why R128Net

Links