Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: The best True Peak detection? (Read 3726 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

The best True Peak detection?

What makes a good TP scan? The higher the oversampling frequency the better, right? But assuming the same Hz, how do you know if one SRC/setting is more accurate than another?

Is there an advantage of whole number upsampling (4x, 8x, ....) over using a fixed samplerate (192k, 500k, ...)? I only see the former being mentioned in this context, but the latter should be more consistent and would avoid the needless resampling of high SR material.

I'm thinking about ReplayGain TP scanning in foobar2000 at the moment and there are a few options there that made me curious... I also ran a few tests and I noticed some big differences between resamplers, at least with one file.

Re: The best True Peak detection?

Reply #1
It really depends on how you define "best" and "accurate". If you don't have a specific target and simply want to reduce the chance of clipping in most scenarios, just aim at mimiking what typical DAC chips do. Most of them use integer oversampling ratios, and with a transistion region from about 0.45fs and stopband at about 0.55fs, for example:
44100*0.45 = 19845
44100*0.55 = 24255
...and phase response from linear to minimum. These factors all contribute to different scanning results.

For official reference, read page 16-17:
https://www.itu.int/rec/R-REC-BS.1770-4-201510-I/en

Which suggests 4x for 48k material and 2x for 96k material, and expected true peak up to 12.04dB.

Here are some real world examples:
https://www.audiosciencereview.com/forum/index.php?threads/practical-example-of-intersample-peak-greater-than-6-dbfs.14095/post-447422
https://hydrogenaud.io/index.php?topic=98753.0

SSRC for example is not a good candidate to estimate dBTP of typical hardware, often results in excessively high value due to the unconfigurable overly steep filter (over 99%).

foo_dsp_resampler is more configurable. For typical usage, use the default value and set the quality to Normal instead of Best, the performace will be close enough to generic real world hardware, with very fast scanning speed.
https://hydrogenaud.io/index.php/topic,67376.0.html

Re: The best True Peak detection?

Reply #2
I'm not convinced this is even an issue...   There is no technical-reason that the reconstruction filter on the DAC's analog output can't go over 0dB without clipping.   The "true peaks" don't exist in the digital domain.  There are only sample-peaks (with nothing in-between samples).

And if the reconstructed analog waveform does clip from inter-sample peaks, has it ever been shown to be audible? 

If you up-sample you can measure the new sample-peaks and re-normalize as necessary.

Re: The best True Peak detection?

Reply #3
I'm not convinced this is even an issue...   There is no technical-reason that the reconstruction filter on the DAC's analog output can't go over 0dB without clipping.   The "true peaks" don't exist in the digital domain.  There are only sample-peaks (with nothing in-between samples).

And if the reconstructed analog waveform does clip from inter-sample peaks, has it ever been shown to be audible? 

If you up-sample you can measure the new sample-peaks and re-normalize as necessary.
That's not true. Most DACs have 8x digital filter for single speed (44.1/48k) sample rate, followed by simpler interpolation methods like zero order hold or linear interpolation to something like 128-256x fs to the modulator BEFORE converting to analog, and this is proved to be able to induce clipping.

It's proved to be audible as well, at least for crafted signal:
https://forum.cockos.com/showthread.php?t=201868

Re: The best True Peak detection?

Reply #4
Using fb2k, the resamplers give quite different results ... and I surely have albums where the RG album peak tag is what determines output loudness.

(I am too lazy to write any fb2k query that converts the track peak to dB and adds the (negative!) RG figure - everything upscaled to be reasonably right with fb2k's integer-only arithmetic - to return those which are positive, or dangerously close.)

Re: The best True Peak detection?

Reply #5
@bennetng : Got it, thanks!

Yeah, I think I'll use the SoX resampler for this, at 95% bandpass. As you suggest, even 95% might be high compared to what most DACs use. But that's okay, since I'm not really targeting anything specific and that 95% setting seems to be close to what some other TP scanners are doing.

Just curious, though, do most DACs use linear phase filters? I would expect minimum phase to be popular, because of the lower latency. Or is the sample rate inside a DAC so high that it's not a real concern?
Changing between linear/minimum showed the biggest differences in peaks for me. But again, most TP scanners' result look like SoX's linear phase setting and not the minimum phase one. This is more evident with the extreme ISP samples.


And since I ran some tests, here are some observations, if anyone cares:
1. Between the 4 resamplers in foobar (incl. SoX), the "auto x4/x8" was consistently the one who stuck out with TP values, on almost all material. SoX and RetroArch (highest quality) were very similar. SSRC was mostly similar to those two as well, but with a few files the result was more different--indeed, it seems because of the high bandpass filter. I then switched to just using SoX.
2. Integer ("whole number") vs non-integer upsampling: Integer is faster. 2x SR (44k to 88k) also seems to produce more accurate TP values than ~2.2x (44k to 96k). By more accurate I mean more similar to the 1MHz scan ("high anchor"). But at higher target rates (4x, 8x) this seems to matter less and TP values become more and more even...
3. ... until 20MHz (the max in SoX), when some different TP values appear again (already at 15MHz too). I don't know what to make of that.
(a tip for doing such comparisons in f2k: put files into different folders for different settings and sort them by folder/file name in foobar)

Re: The best True Peak detection?

Reply #6
@bennetng : Got it, thanks!
Just curious, though, do most DACs use linear phase filters? I would expect minimum phase to be popular, because of the lower latency. Or is the sample rate inside a DAC so high that it's not a real concern?
Changing between linear/minimum showed the biggest differences in peaks for me. But again, most TP scanners' result look like SoX's linear phase setting and not the minimum phase one. This is more evident with the extreme ISP samples.
I tested my Realtek ALC892 and a soundcard with PCM1794A, they both have linear phase filters. On the other hand another soundcard with a CS4382 has an intermediate phase filter. So none of them are minimum phase. Some DACs offer user-selectable filters with different steepness and phase settings.

Another thing is that most DAC filters have some degrees of imaging, which can be mimicked by checking the "Allow aliasing/imaging" box in the SoX plugin.

Steepness and imaging usually only affect audio files with high amount of near Nyquist content, like unfiltered chiptunes and electronic music. Some loudness war files are actually somewhat lowpassed instead of hard-clipped. So yes, phase is an important factor. If you are paranoid, scan in both linear and minimum phase and get what showed the highest.

Quote
And since I ran some tests, here are some observations, if anyone cares:
1. Between the 4 resamplers in foobar (incl. SoX), the "auto x4/x8" was consistently the one who stuck out with TP values, on almost all material. SoX and RetroArch (highest quality) were very similar. SSRC was mostly similar to those two as well, but with a few files the result was more different--indeed, it seems because of the high bandpass filter. I then switched to just using SoX.
2. Integer ("whole number") vs non-integer upsampling: Integer is faster. 2x SR (44k to 88k) also seems to produce more accurate TP values than ~2.2x (44k to 96k). By more accurate I mean more similar to the 1MHz scan ("high anchor"). But at higher target rates (4x, 8x) this seems to matter less and TP values become more and more even...
3. ... until 20MHz (the max in SoX), when some different TP values appear again (already at 15MHz too). I don't know what to make of that.
That's why the official BS.1770 document only recommends 4x for signle speed materials and 2x for double speed materials, and -1dBTP output to give headroom for uncertainties.