To measure True Peak, MathWorks's Matlab Help Center page suggests:
- The signal is over-sampled to at least 192 kHz.
- The over-sampled signal,
a
, passes through a low-pass filter with a half-poly-phase length of 12 and stop-band attenuation of 80 dB. - The filtered signal,
b
, is rectified and converted to the dBTP scale:c = 20×log10(∣b∣)
- The true-peak is determined as the maximum of the converted signal,
c
.
My simple implementation:
f = "impulse_1.wav";
info = audioinfo (f);
[X, fs] = audioread(f);
p = 4;
q = 1;
Y = resample(X, p, q);
dBTP = 20 * log10( max(max(abs(Y))) );
results dBTP = 2.094 (for the file in code) which is close to the theoretical value (+2.098) mentioned on site where from the test audio file comes. For second test file there (impulse_2.wav) result is not as close to the theoretical value (+0.765) but shows +0.6662. Both measures seem to pass the error criteria TP standard gives (0.1dB).
I've read people use different types of interpolators and window functions in their implementations but, the results still have lots of variation as what this ISP/True Peak limiter test shows.
I did implement another test method by following instructions above:
p = 4;
Y1 = zeros(1, length(X)*p);
for i = (1:length(X))
Y1(i*p-(p-1))= X(i);
endfor
b = designMultirateFIR(p,1);
% b = designMultirateFIR(p,1,0.01,80)
Y1 = filter(b,1,Y1);
for i = 1:length(Y1)
m = 20*log10(abs(Y1(i)));
if m > max_tp
max_tp = m;
endif
endfor
max_tp
and ran the same test (but using various up-sampling factors) with results:
>> [dBTP, max_tp] = max_true_peak(2)
dBTP = 2.0940
max_tp = 2.0429
>> [dBTP, max_tp] = max_true_peak(3)
dBTP = 1.8681
max_tp = 1.8228
>> [dBTP, max_tp] = max_true_peak(4)
dBTP = 2.0940
max_tp = 2.0429
>> [dBTP, max_tp] = max_true_peak(5)
dBTP = 2.0129
max_tp = 1.9638
>> [dBTP, max_tp] = max_true_peak(6)
dBTP = 2.0940
max_tp = 2.0429
>> [dBTP, max_tp] = max_true_peak(7)
dBTP = 2.0526
max_tp = 2.0025
>> [dBTP, max_tp] = max_true_peak(8)
dBTP = 2.0940
max_tp = 2.0429
dBTP results got from 1st implementation.
It seems like the test files are working correctly for those even oversampling ratios only. I tried many parameters for low-pass implementation and found out that low-pass implementation effects the results quite a bit as well.
Now, my questions regarding those parts I don't understand. If I want to use interpolation and/or windowing to get the peak values ... .
- is interpolation done in resampling process or after that (where exactly) ? Actually, I made another implementation where resampled data was interpolated using cubic spline interpolation to find the TP and it seemed to work otherwise but was really (too) slow operation.
- if I want to try
n
tap FIR interpolator withx
window over-sampledp
times ... what does that actually mean (my initial guess: oversample using FIR interpolator, feed the result through window function)? - which windowing method would suite best in this task (TP measuring)
- as metering should be fast (on-line processing), which oversampling and interpolation methods are best suitable