grame-cncm / faustlibraries

The Faust libraries
https://faustlibraries.grame.fr
183 stars 59 forks source link

ITU-R BS.1770-4 "K-filter" #145

Closed jkbd closed 1 year ago

jkbd commented 1 year ago

@sletz here we go: I added the K-filter itu_r_bs_1770_4_kfilter within a new section "Standardized Filters". You suggested adding the filter over here: https://github.com/trummerschlunk/master_me/issues/16#issuecomment-1214904902.

I think, there are a more standardized filters, that could be added in the future. However, please feel free to move the code, if another section or file would be more appropriate.

Does the code in this pull-request meet all the testing requirements of the FAUST libraries?

sletz commented 1 year ago

Moved a bit and merged thanks! Feel free to contribute more standardized filters.

dariosanfilippo commented 1 year ago

@sletz here we go: I added the K-filter itu_r_bs_1770_4_kfilter within a new section "Standardized Filters". You suggested adding the filter over here: trummerschlunk/master_me#16 (comment).

I think, there are a more standardized filters, that could be added in the future. However, please feel free to move the code, if another section or file would be more appropriate.

Does the code in this pull-request meet all the testing requirements of the FAUST libraries?

(Reposting here as my email reply didn't go through, apparently.)

Hi, @jkbd , and thanks for your contribution.

I was convinced that the k-filter from the specs was a combination of a HP Butterworth and a high-shelving Butterworth, respectively with a cutoff of 37.5 Hz and 1500 Hz, the latter one having a gain of 4 dB.

I plotted the impulse responses of the biquad sections using the coefficients from the specs, your filter, and the aforementioned filters based on Zavalishin's SVF.

Ch0 is the specs, ch1 is your filter, and ch2 is Zavalishin's. The red dotted h-lines cross the -3.01 and 2 dB points, whereas the red v-lines cross the frequencies at 37.5 and 1500 Hz. That's at 48kHz SR.

image

It doesn't look like the HP from the specs is matching what I thought to be correct; do you know if that filter should be different?

Ciao, Dr Dario Sanfilippo http://dariosanfilippo.com/

jkbd commented 1 year ago

Hello @dariosanfilippo,

the difference between ch0 and ch1 is mostly due to my normalization and some invisible tiny bit due to not rounding coefficients. As shown in this Gist, I started from the original coefficients published by EBU. And since my calculation did not result in a normalization of exactly -0.691dB, I decided to "bake it in". The standard confuses me, since 0.691dB corresponds better to the magnitude at 997Hz instead of 1000Hz (as written).

Footnote: I think, measuring at 997Hz (which is the closest prime number to 1000) instead of 1000Hz, is to avoid effects due to test-frequency and samplerate having a common divisor. Unfortunately, I forgot where I read about that.

On the difference between ch0 and ch2: I did not know about "Zavalishin's SVF". From my calculations the Q-factor of the highpass filter is clearly not Butterworth (Q=1/sqrt(2)) but Q=0.5. Since I am quiet new to DSP, I am hesitant with bold statements, but Zavalishin's filter does not seem to comply with the specs.

Do you know where the term "K-filter" comes from? Is there literature, that explains the relation between head-diameter and shelving-filter? I read a bit from Bob Katz, but I could not find a filter specified in any K-metering publication.

dariosanfilippo commented 1 year ago

Hi, @jkbd.

It is questionable that the standard doesn't provide a clear specification for the filters or coefficients covering at least the four most common sample rates.

I was convinced that the HP was a Butterworth because of something that I had read on a JUCE forum post and what a friend of mine had worked out, but I can also see that the HP from the specs has a Q of -6 dB by looking at the plot and this is indeed the best match I've found so far:

image

Zavalishin's filters should have just the same response as, say, RBJ's filters; however, they behave better when time-variant, so they're still second-order filters with adjustable parameters.

I don't know much about K-filters as you could see. :-)

Cheers, Dario

dariosanfilippo commented 1 year ago

Hi, Jacob, and thanks for your contribution.

I was convinced that the k-filter from the specs was a combination of a HP Butterworth and a high-shelving Butterworth, respectively with a cutoff of 37.5 Hz and 1500 Hz, the latter one having a gain of 4 dB.

I plotted the impulse responses of the biquad sections using the coefficients from the specs, your filter, and the aforementioned filters based on Zavalishin's SVF.

Ch0 is the specs, ch1 is your filter, and ch2 is Zavalishin's. The red dotted h-lines cross the -3.01 and 2 dB points, whereas the red v-lines cross the frequencies at 37.5 and 1500 Hz. That's at 48kHz SR.

[image: image.png]

It doesn't look like the HP from the specs is matching what I thought to be correct; do you know if that filter should be different?

Ciao, Dr Dario Sanfilippo http://dariosanfilippo.com

On Wed, 7 Sept 2022 at 18:56, Jakob Dübel @.***> wrote:

@sletz https://github.com/sletz here we go: I added the K-filter itu_r_bs_1770_4_kfilter within a new section "Standardized Filters". You suggested adding the filter over here: trummerschlunk/master_me#16 (comment) https://github.com/trummerschlunk/master_me/issues/16#issuecomment-1214904902 .

I think, there are a more standardized filters, that could be added in the future. However, please feel free to move the code, if another section or file would be more appropriate.

Does the code in this pull-request meet all the testing requirements of the FAUST libraries?

You can view, comment on, or merge this pull request online at:

https://github.com/grame-cncm/faustlibraries/pull/145 Commit Summary

File Changes

(1 file https://github.com/grame-cncm/faustlibraries/pull/145/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faustlibraries/pull/145, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHG3I2DEK7LQBMEMNGJIOO3V5DCKTANCNFSM6AAAAAAQG6OMRE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sletz commented 1 year ago

Where is the [image: image.png] ?

jkbd commented 1 year ago

@dariosanfilippo, I tried to document what I did as clear as possible. I quoted where I got the numbers and I shared the code of what I did. On the opposite, you are convinced with something, expect me to know Zavalishin's publications or who RBJ is, plot something somehow and ask me the same question, that I answered before, again. Sorry, I don't know a better answer to your question or I did not understand it.

dariosanfilippo commented 1 year ago

I did not resend the same message that I had sent a month ago; I assume that GitHub might have messed up.

jkbd commented 1 year ago

Okay, nevermind then.

P.S.: Github, how did you get my name wrong?