csteinmetz1/pyloudnorm

Implement filters that match standard based on Brecht's paper

Closed this issue · 1 comments

The current biquad filter implementations, which are based on RBJ's cookbook formulae, produce filter coefficients which differ slightly from the provided K-weighting filter coefficients. This paper defines equations that will produce filter coefficients that 'exactly' match those given in the ITU-R BS.1770 standard. I would like to find a way to incorporate these filter coefficients as an option. I think this should be as easy as just adding two new elif statements similiar to below.

 if self.filter_type == 'high_shelf': # preexisting filter 
            b0 =      A * ( (A+1) + (A-1) * np.cos(w0) + 2 * np.sqrt(A) * alpha )
            b1 = -2 * A * ( (A-1) + (A+1) * np.cos(w0)                          )
            b2 =      A * ( (A+1) + (A-1) * np.cos(w0) - 2 * np.sqrt(A) * alpha )
            a0 =            (A+1) - (A-1) * np.cos(w0) + 2 * np.sqrt(A) * alpha
            a1 =      2 * ( (A-1) - (A+1) * np.cos(w0)                          )
            a2 =            (A+1) - (A-1) * np.cos(w0) - 2 * np.sqrt(A) * alpha
 elif self.filter_type == 'high_shelf_DeMan':
                  .
                  .
                  .
 elif self.filter_type == 'high_pass_DeMan':
                  .
                  .
                  .       

See Brecht's implementation here for reference.

Addressed this in #20.