I’m trying to implement the “K” frequency weighting filter as described in ITU-R BS.1770-4 (p. 3-5) using SOS.ar
. This filter is a simple cascade of two second-order filter sections (biquads), namely a high shelving filter and a high-pass filter. The biquad coefficients in the paper are given for a fixed sample rate (fs=48000
).
I’ve made sure
- that my server is running at that exact sample rate,
- that the coefficients are given in the correct order (the feedback/feedforward coefficient naming is reversed in the paper, so
SOS.ar
’sa0, a1, a2
are calledb0, b1, b2
in the paper), and - that these exact coefficients are working as expected in Max’s
biquad~
object,
but SOS.ar
still blows up. The same thing happens with LTI.ar
from sc3-plugins. I’ve tested this with both the high shelf and lowpass coefficients given in the paper. Here’s my code, make sure to mute your server outs before executing the second block:
s = s ?? { Server.default };
s.sampleRate; // -> 48000.0, no issues there
// !!!
// WARNING: MUTE BEFORE EXECUTING THIS BLOCK
// !!!
(
// valid filter coefficients for a sample rate of 48000 Hz
// given in ITU-R BS.1770-4
var a0, a1, a2, b1, b2;
// values from paper
// shelf
b1 = 1.69065929318241.neg;
b2 = 0.73248077421585;
a0 = 1.53512485958697;
a1 = 2.69169618940638.neg;
a2 = 1.19839281085285;
// hp
// b1 = 1.99004745483398.neg;
// b2 = 0.99007225036621;
// a0 = 1.0;
// a1 = 2.0.neg;
// a2 = 1.0;
{
SOS.ar(WhiteNoise.ar, a0, a1, a2, b1, b2) * -30.dbamp ! 2;
}.play
)
Does anyone know why this happens? I know FluidLoudness.kr
exists, but I want to have a stab at rolling my own “perceptually” weighted filters for other purporses (e.g. to use in a compressor before the envelope calculation stage).