Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Choice of True Peak Filter Coefficients #10

Closed
domchristie opened this issue Apr 22, 2020 · 3 comments
Closed

[Question] Choice of True Peak Filter Coefficients #10

domchristie opened this issue Apr 22, 2020 · 3 comments
Labels

Comments

@domchristie
Copy link

Hey there! Great app, and thanks for open-sourcing it.
I'm trying to create my own true peak meter and am researching various implementations.
Just wondered what the thinking was behind calculating the filter coefficients for the true peak interpolation filter rather than using those specified in ITU-R BS.1770-4?
Any help or pointers are greatly appreciated, thanks!

@audionuma
Copy link
Owner

audionuma commented Apr 23, 2020

Hello. The code you are mentioning is part of libebur128 and the interpolator (https://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula) part has been mostly implemented by @bmatherly (jiixyj/libebur128#51).
He might be a better source to explain the reasoning behind.

@bmatherly
Copy link

The pull request that @audionuma linked to tells the whole story. It would be good for someone to map some of that discussion into some code comments for future reference.

TLDR:
This implementation uses the sinc/windowed method with odd filter taps at the nyquist frequency. The sinc coefficients end up being zero for every other coefficient (except the middle) and the hanning window zeros out the first and last coeffficient. So the total number of multiply/add operations per sample for 49 taps comes to ((48 x 3 / 4) + 1 - 2) / 4 = 8.75 for this implementation.

Compare that to the example filter provided by BS.1770-4 for 48 taps. The total number of multiply/add operations per sample comes to 48 / 4 = 12

So this method is 27% more efficient than the BS.1770-4 example.

You can trade performance for quality by reducing the number of filter taps (but keep the number odd to take advantage of the "zero" side-effect).

@domchristie
Copy link
Author

@audionuma @bmatherly Thank you so much! Having read up on interpolation filters from Watkinson's The Art of Digital Audio, this is how I expected them all to work:

[for an upsampling factor of 4,] three sets of coefficients will be used in turn. In hardware-implemented filters, the input sample which is passed straight to the output is transferred using a fourth filter phase where all coefficients are zero except the central one which is unity.

(Perhaps erroneously) I applied the spec's original coefficients in the same way. The results were within the error bounds but generating the coefficients manually yields more accurate results (using the EBU test samples). Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants