Hello, I'm trying to set up a java program to make EBU R 128 measures on audio files. ( http://tech.ebu.ch/docs/r/r128.pdf ) I have an issue with the True Peak measurement. It is basically described as four times oversampling the original signal by : padding the signal with zeros applying a low pass filter Here's a basic java source code : public class TestOversample { public static void main(String[] args){ /* * 192 kHz sampling frequency low pass filter coefs * from http://www-users.cs.york.ac.uk/~fisher/mkfilter/racos.html */ int NZEROS = 32; Double GAIN = 4.000723948e+00; Double[] xv = new Double[NZEROS + 1]; for(int i = 0; i < xv.length; i++){ xv[i] = 0.0; } Double xcoeffs[] = { +0.0000000000, +0.0003771338, +0.0006574619, +0.0004365828, +0.0000000000, +0.0013575628, +0.0062416035, +0.0102432190, +0.0000000000, -0.0362811310, -0.0859543245, -0.0974577653, -0.0000000000, +0.2421533912, +0.5791942445, +0.8793939953, +1.0000000000, +0.8793939953, +0.5791942445, +0.2421533912, -0.0000000000, -0.0974577653, -0.0859543245, -0.0362811310, +0.0000000000, +0.0102432190, +0.0062416035, +0.0013575628, +0.0000000000, +0.0004365828, +0.0006574619, +0.0003771338, +0.0000000000}; Double [] input, paddedInput, output; Double inputPeak = 0.0, outputPeak = 0.0; /*building a test input * a 0 dBFS 997 Hz sin @ 48 kHz * and checking the max sample peak */ input = new Double[512]; for(int i = 0; i < input.length; i ++){ input[i] = Math.sin(2*Math.PI*997*i/48000); if(Math.abs(input[i]) > inputPeak){inputPeak = Math.abs(input[i]);} } /* * padding the input for a 192 kHz sampling frequency */ paddedInput = new Double[4*input.length]; for(int i = 0; i < paddedInput.length; i++){ if(i % 4 == 0){ paddedInput[i] = input[i/4]; } else{ paddedInput[i] = 0.0; } } /* * filtering the paddedInput * */ output = new Double[paddedInput.length]; Double sum; for(int i = 0; i < paddedInput.length; i++){ for(int j = 0; j < NZEROS; j++){ xv[j] = xv[j+1]; } xv[NZEROS] = paddedInput[i]/GAIN; sum = 0.0; for(int j = 0; j <= NZEROS; j++){ sum += (xcoeffs[j]*xv[j]); } output[i] = sum; if(Math.abs(output[i]) > outputPeak){outputPeak = output[i];} } System.out.println(inputPeak + " " + outputPeak); } } The issue I have is that the outputPeak is about 0.25*inputPeak, where I would have expected that it would be at least the same, or more in case of signals having intersamples peaks. So am I missing the whole point ? Is the filter not fitted for that purpose ? Thanks,
True Peak Measure
Started by ●November 14, 2010
Reply by ●November 14, 20102010-11-14
Manuel Naudin wrote:> Hello, > I'm trying to set up a java program to make EBU R 128 measures on > audio files. ( http://tech.ebu.ch/docs/r/r128.pdf ) > I have an issue with the True Peak measurement. It is basically > described as four times oversampling the original signal by : > padding the signal with zeros > applying a low pass filter> The issue I have is that the outputPeak is about 0.25*inputPeak, where > I would have expected that it would be at least the same, or more in > case of signals having intersamples peaks. > So am I missing the whole point ? Is the filter not fitted for that > purpose ?This is what expected as you diluted the original signal by the factor of 4 by padding it with zeroes. Make up the gain accordingly. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●November 14, 20102010-11-14
Vladimir Vassilevsky <nospam@nowhere.com> wrote:>Manuel Naudin wrote:>> I'm trying to set up a java program to make EBU R 128 measures on >> audio files. ( http://tech.ebu.ch/docs/r/r128.pdf ) >> The issue I have is that the outputPeak is about 0.25*inputPeak, where >> I would have expected that it would be at least the same, or more in >> case of signals having intersamples peaks.>This is what expected as you diluted the original signal by the factor >of 4 by padding it with zeroes. Make up the gain accordingly.I agree, and after fixing this I would test the result with a signal constructed as follows: sine wave signal, mid-band, whose peaks lie exactly on the original sample points before interpolation. The "true peak" measurement should equal the observed peaks of the original signal. You may find that it deviates somewhat at the band edge. Steve
Reply by ●November 15, 20102010-11-15
On 14 nov, 21:45, spop...@speedymail.org (Steve Pope) wrote:> Vladimir Vassilevsky �<nos...@nowhere.com> wrote: > > >Manuel Naudin wrote: > >> I'm trying to set up a java program to make EBU R 128 measures on > >> audio files. (http://tech.ebu.ch/docs/r/r128.pdf) > >> The issue I have is that the outputPeak is about 0.25*inputPeak, where > >> I would have expected that it would be at least the same, or more in > >> case of signals having intersamples peaks. > >This is what expected as you diluted the original signal by the factor > >of 4 by padding it with zeroes. Make up the gain accordingly. > > I agree, and after fixing this I would test the result with a signal > constructed as follows: sine wave signal, mid-band, whose peaks lie > exactly on the original sample points before interpolation. > > The "true peak" measurement should equal the observed peaks of > the original signal. �You may find that it deviates somewhat > at the band edge. > > SteveThanks a lot Vladimir and Steve. I will do the tests suggested by Steve. I also have to do some tests that 'reveal' intersamples peaks, not sure yet of what original signal I have to use. (Well, a 48 kHz signal whose peaks lie between samples I guess ;-)).
Reply by ●November 15, 20102010-11-15
On Nov 15, 5:46�am, Manuel Naudin <audion...@gmail.com> wrote:> I also have to do some tests that 'reveal' intersamples peaks, not > sure yet of what original signal I have to use. (Well, a 48 kHz signal > whose peaks lie between samples I guess ;-)).Right... are you aware of Nyquist's sampling theorem? Rune
Reply by ●November 15, 20102010-11-15
On 15 nov, 05:57, Rune Allnor <all...@tele.ntnu.no> wrote:> On Nov 15, 5:46�am, Manuel Naudin <audion...@gmail.com> wrote: > > > I also have to do some tests that 'reveal' intersamples peaks, not > > sure yet of what original signal I have to use. (Well, a 48 kHz signal > > whose peaks lie between samples I guess ;-)). > > Right... are you aware of Nyquist's sampling theorem? > > RuneWell, I think I am aware of it, but not being a dsp engineer or a professional programmer, there obviously is a lot I have to learn (or at least understand). For those interested in the loudness measurement field, I have setup an open source project here : http://code.google.com/p/jloudnessmeter/
Reply by ●November 15, 20102010-11-15
On Sun, 14 Nov 2010 10:05:35 -0600, Vladimir Vassilevsky <nospam@nowhere.com> wrote:> > >Manuel Naudin wrote: > >> Hello, >> I'm trying to set up a java program to make EBU R 128 measures on >> audio files. ( http://tech.ebu.ch/docs/r/r128.pdf ) >> I have an issue with the True Peak measurement. It is basically >> described as four times oversampling the original signal by : >> padding the signal with zeros >> applying a low pass filter > >> The issue I have is that the outputPeak is about 0.25*inputPeak, where >> I would have expected that it would be at least the same, or more in >> case of signals having intersamples peaks. >> So am I missing the whole point ? Is the filter not fitted for that >> purpose ? > >This is what expected as you diluted the original signal by the factor >of 4 by padding it with zeroes. Make up the gain accordingly. > > >Vladimir VassilevskyHi Valdimir, Yep, that's right. What Manuel should experiment with is, instead of stuffing those three zero-valued samples between each original time sample, repeating the last original sample value three times. (A kind of "zero-order-hold".) He might be happier with the filtered results. See Ya', [-Rick-]
Reply by ●November 15, 20102010-11-15
On Nov 15, 12:35�pm, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote:> On Sun, 14 Nov 2010 10:05:35 -0600, Vladimir Vassilevsky > > > > <nos...@nowhere.com> wrote: > > >Manuel Naudin wrote: > > >> Hello, > >> I'm trying to set up a java program to make EBU R 128 measures on > >> audio files. (http://tech.ebu.ch/docs/r/r128.pdf) > >> I have an issue with the True Peak measurement. It is basically > >> described as four times oversampling the original signal by : > >> padding the signal with zeros > >> applying a low pass filter > > >> The issue I have is that the outputPeak is about 0.25*inputPeak, where > >> I would have expected that it would be at least the same, or more in > >> case of signals having intersamples peaks. > >> So am I missing the whole point ? Is the filter not fitted for that > >> purpose ? > > >This is what expected as you diluted the original signal by the factor > >of 4 by padding it with zeroes. Make up the gain accordingly. > > >Vladimir Vassilevsky > > Hi Valdimir, > � Yep, that's right. �What Manuel should > experiment with is, instead of stuffing those > three zero-valued samples between each > original time sample, repeating the last > original sample value three times. �(A kind > of "zero-order-hold".) > > He might be happier with the filtered results. > > See Ya', > [-Rick-]Rick, perhaps the OP should buy your book and read chapter 10 like some of us already have. P.S. was the zero order hold suggestion serious? I understood that zero stuffing produces "ideal" spectral images to be filtered out by the LPF and so is the way to go, or am I missing something? Does repeating samples make things easier somehow? I would have thought (intuitively for me anyway) it would add some form of distortion into the mix. P.S. my previous thread is on the very same subject as this. Thanks, Dave
Reply by ●November 15, 20102010-11-15
davew wrote:> On Nov 15, 12:35 pm, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote: > >>On Sun, 14 Nov 2010 10:05:35 -0600, Vladimir Vassilevsky >> >> >> >><nos...@nowhere.com> wrote: >> >> >>>Manuel Naudin wrote: >> >>>>Hello, >>>>I'm trying to set up a java program to make EBU R 128 measures on >>>>audio files. (http://tech.ebu.ch/docs/r/r128.pdf) >>>>I have an issue with the True Peak measurement. It is basically >>>>described as four times oversampling the original signal by : >>>>padding the signal with zeros >>>>applying a low pass filter >> >>>>The issue I have is that the outputPeak is about 0.25*inputPeak, where >>>>I would have expected that it would be at least the same, or more in >>>>case of signals having intersamples peaks. >>>>So am I missing the whole point ? Is the filter not fitted for that >>>>purpose ? >> >>>This is what expected as you diluted the original signal by the factor >>>of 4 by padding it with zeroes. Make up the gain accordingly. >> >>>Vladimir Vassilevsky >> >>Hi Valdimir, >> Yep, that's right. What Manuel should >>experiment with is, instead of stuffing those >>three zero-valued samples between each >>original time sample, repeating the last >>original sample value three times. (A kind >>of "zero-order-hold".) >> >>He might be happier with the filtered results. >> >>See Ya', >>[-Rick-] > > > Rick, > perhaps the OP should buy your book and read chapter 10 like some of > us already have. P.S. was the zero order hold suggestion serious? I > understood that zero stuffing produces "ideal" spectral images to be > filtered out by the LPF and so is the way to go, or am I missing > something? Does repeating samples make things easier somehow? I > would have thought (intuitively for me anyway) it would add some form > of distortion into the mix. > P.S. my previous thread is on the very same subject as this. > Thanks, > DaveYou can look at zero order hold as a boxcar filter with sin(x)/x frequency response. This will simplify the subsequent filtering as it attenuates the upper images, however it will also introduce ~ 4dB rolloff near Nyquist of the "fundamental" image. IIRC the OP is using IIR filter. I would rather make an equvalent polyphase FIR, rather then doing zero-order-hold + IIR; however it depends on the application. VLV
Reply by ●November 15, 20102010-11-15
On Nov 15, 5:38�pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:> davew wrote: > > On Nov 15, 12:35 pm, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote: > > >>On Sun, 14 Nov 2010 10:05:35 -0600, Vladimir Vassilevsky > > >><nos...@nowhere.com> wrote: > > >>>Manuel Naudin wrote: > > >>>>Hello, > >>>>I'm trying to set up a java program to make EBU R 128 measures on > >>>>audio files. (http://tech.ebu.ch/docs/r/r128.pdf) > >>>>I have an issue with the True Peak measurement. It is basically > >>>>described as four times oversampling the original signal by : > >>>>padding the signal with zeros > >>>>applying a low pass filter > > >>>>The issue I have is that the outputPeak is about 0.25*inputPeak, where > >>>>I would have expected that it would be at least the same, or more in > >>>>case of signals having intersamples peaks. > >>>>So am I missing the whole point ? Is the filter not fitted for that > >>>>purpose ? > > >>>This is what expected as you diluted the original signal by the factor > >>>of 4 by padding it with zeroes. Make up the gain accordingly. > > >>>Vladimir Vassilevsky > > >>Hi Valdimir, > >> �Yep, that's right. �What Manuel should > >>experiment with is, instead of stuffing those > >>three zero-valued samples between each > >>original time sample, repeating the last > >>original sample value three times. �(A kind > >>of "zero-order-hold".) > > >>He might be happier with the filtered results. > > >>See Ya', > >>[-Rick-] > > > Rick, > > perhaps the OP should buy your book and read chapter 10 like some of > > us already have. �P.S. was the zero order hold suggestion serious? �I > > understood that zero stuffing produces "ideal" spectral images to be > > filtered out by the LPF and so is the way to go, or am I missing > > something? �Does repeating samples make things easier somehow? �I > > would have thought (intuitively for me anyway) it would add some form > > of distortion into the mix. > > P.S. my previous thread is on the very same subject as this. > > Thanks, > > Dave > > You can look at zero order hold as a boxcar filter with sin(x)/x > frequency response. This will simplify the subsequent filtering as it > attenuates the upper images, however it will also introduce ~ 4dB > rolloff near Nyquist of the "fundamental" image. IIRC the OP is using > IIR filter. I would rather make an equvalent polyphase FIR, rather then > doing zero-order-hold + IIR; however it depends on the application. > > � VLVOK thanks VLV, penny just dropped I think. Rick mentions this (CIC filter method) in his book too. As you say application dependent, for me at least, I think the zero stuff followed by polyphase FIR is the appropriate tack.