Vixen
02b45cc4
csharp
public sealed class TruePeakMeter

Finds the peak of the waveform a converter will actually produce.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Sample peak is not the peak. The samples are points on a curve, and the curve a reconstruction filter draws through them passes between them — over the top of the highest one, when the signal is near full scale and not aligned to the sample grid. A mix that reads −1.0 dBFS on sample peak can be at −0.3 dBTP in the analogue domain, and clip a converter that had every right to expect headroom.

Two things care, and neither of them is subtle. Console certification specifies a true-peak ceiling — typically −1 dBTP — and sample peak is not what it measures. And lossy encoding: a signal sitting at 0 dBFS sample peak clips when it is encoded to Opus and decoded again, because the codec's own reconstruction overshoots too. The headroom protects against both.

Four times, because that is what the standard asks for and because it is enough: the residual error of a 4× oversampled peak is a couple of tenths of a decibel, which is inside the margin any sane ceiling leaves. Sixteen times would be more accurate and would cost four times as much to find out something nobody acts on.

The filter is derived rather than tabled. BS.1770 prints one set of coefficients for 48 kHz; a meter that used them at 44.1 would be interpolating with a filter whose cutoff is in the wrong place. A windowed sinc built for the phase count works at any rate, because the interpolation is between samples and knows nothing about how fast they arrive.

Fields and properties (5)

  • public const int Oversampling

    How many points are evaluated between each pair of samples, including the sample.

  • public const int Taps

    How many input samples each interpolated point is drawn from.

  • public float Peak

    The highest true peak seen since the last Reset, as a linear amplitude.

  • public float PeakDbTp

    The same in decibels relative to full scale, which is the unit a ceiling is written in.

  • public int Channels

    How many channels it is metering.

Methods (3)

  • public TruePeakMeter(int channelCount)

    A meter over some channels.

  • public void Push(int channel, float sample)

    Takes one sample of one channel.

  • public void Reset()

    Forgets the reading and the history.

Used by (2)

  • LoudnessMeterEffectVixen.Audio
  • TruePeakTestsVixen.Audio.Tests