def c_weighting_coeffs_design(sample_rate):
    """Returns b and a coeff of a C-weighting filter.
    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.
    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.
    Examples
    --------
    b, a = c_weighting_coeffs_design(sample_rate)
    To Filter a signal use scipy lfilter:
    from scipy.signal import lfilter
    y = lfilter(b, a, x)
    See Also
    --------
    a_weighting_coeffs_design : A-Weighting coefficients.
    b_weighting_coeffs_design : B-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.
    """

    f1 = 20.598997
    f4 = 12194.217
    C1000 = 0.0619
    numerators = [(2 * pi * f4)**2 * (10**(C1000 / 20)), 0, 0]
    denominators = convolve([1, +4 * pi * f4, (2 * pi * f4)**2],
                            [1, +4 * pi * f1, (2 * pi * f1)**2])
    return bilinear(numerators, denominators, sample_rate)
def b_weighting_coeffs_design(sample_rate):
    """Returns `b` and `a` coeff of a B-weighting filter.
    B-Weighting is no longer described in DIN61672.
    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.
    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.
    Examples
    --------
    >>> b, a = b_weighting_coeff_design(sample_rate)
    To Filter a signal use :function: scipy.lfilter:
    >>> from scipy.signal import lfilter
    >>> y = lfilter(b, a, x)
    See Also
    --------
    a_weighting_coeffs_design : A-Weighting coefficients.
    c_weighting_coeffs_design : C-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.
    """

    f1 = 20.598997
    f2 = 158.5
    f4 = 12194.217
    B1000 = 0.17
    numerators = [(2 * pi * f4)**2 * (10**(B1000 / 20)), 0, 0, 0]
    denominators = convolve([1, +4 * pi * f4, (2 * pi * f4)**2],
                            [1, +4 * pi * f1, (2 * pi * f1)**2])
    denominators = convolve(denominators, [1, 2 * pi * f2])
    return bilinear(numerators, denominators, sample_rate)
def a_weighting_coeffs_design(sample_rate):
    """Returns b and a coeff of a A-weighting filter.
    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.
    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.
    Examples
    --------
    >>> b, a = a_weighting_coeff_design(sample_rate)
    To Filter a signal use scipy lfilter:
    >>> from scipy.signal import lfilter
    >>> y = lfilter(b, a, x)
    See Also
    --------
    b_weighting_coeffs_design : B-Weighting coefficients.
    c_weighting_coeffs_design : C-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.
    scipy.lfilter : Filtering signal with `b` and `a` coefficients.
    """

    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997
    numerators = [(2 * pi * f4)**2 * (10**(A1000 / 20.0)), 0., 0., 0., 0.]
    denominators = convolve([1., +4 * pi * f4, (2 * pi * f4)**2],
                            [1., +4 * pi * f1, (2 * pi * f1)**2])
    denominators = convolve(convolve(denominators, [1., 2 * pi * f3]),
                            [1., 2 * pi * f2])
    return bilinear(numerators, denominators, sample_rate)
   def C_weighting(self, fs):
      f1 = 20.598997 
      f4 = 12194.217
      C1000 = 0.0619

      NUMs = [(2*pi*f4)**2*(10**(C1000/20.0)),0,0]
      DENs = polymul([1,4*pi*f4,(2*pi*f4)**2.0],[1,4*pi*f1,(2*pi*f1)**2]) 

 
      return bilinear(NUMs,DENs,fs)
Esempio n. 5
0
def a_weighting_coeffs_design(sample_rate):
    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997
    numerators = [(2 * pi * f4)**2 * (10**(A1000 / 20.0)), 0., 0., 0., 0.]
    denominators = convolve([1., +4 * pi * f4, (2 * pi * f4)**2],
                            [1., +4 * pi * f1, (2 * pi * f1)**2])
    denominators = convolve(convolve(denominators, [1., 2 * pi * f3]),
                            [1., 2 * pi * f2])
    return bilinear(numerators, denominators, sample_rate)
Esempio n. 6
0
def A_weighting_filter(fs):
    """construct an a-weighting filter at the specified samplerate
    from here: http://www.mathworks.com/matlabcentral/fileexchange/69
    """
    f1, f2, f3, f4, A1000 = 20.598997, 107.65265, 737.86223, 12194.217, 1.9997

    NUMs = [(2 * np.pi * f4) ** 2 * (10 ** (A1000/20)), 0, 0, 0, 0]
    DENs = np.convolve([1, 4 * np.pi * f4, (2 * np.pi * f4) ** 2],
                       [1, 4 * np.pi * f1, (2 * np.pi * f1) ** 2], mode='full')
    DENs = np.convolve(np.convolve(DENs, [1, 2 * np.pi * f3], mode='full'),
                       [1, 2 * np.pi * f2], mode='full')

    return bilinear(NUMs, DENs, fs)
def a_weight_filter(sample_rate):
    # Definition of analog A-weighting filter according to IEC/CD 1672.
    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997
    numerators = [(2 * pi * f4)**2 * (10**(A1000 / 20.0)), 0., 0., 0., 0.]
    denominators = convolve([1., +4 * pi * f4, (2 * pi * f4)**2],
                            [1., +4 * pi * f1, (2 * pi * f1)**2])
    denominators = convolve(convolve(denominators, [1., 2 * pi * f3]),
                            [1., 2 * pi * f2])
    return bilinear(numerators, denominators, sample_rate)
Esempio n. 8
0
def A_weighting_filter(fs):
    """construct an a-weighting filter at the specified samplerate
    from here: http://www.mathworks.com/matlabcentral/fileexchange/69
    """
    f1, f2, f3, f4, A1000 = 20.598997, 107.65265, 737.86223, 12194.217, 1.9997

    NUMs = [(2 * np.pi * f4)**2 * (10**(A1000 / 20)), 0, 0, 0, 0]
    DENs = np.convolve([1, 4 * np.pi * f4, (2 * np.pi * f4)**2],
                       [1, 4 * np.pi * f1, (2 * np.pi * f1)**2],
                       mode='full')
    DENs = np.convolve(np.convolve(DENs, [1, 2 * np.pi * f3], mode='full'),
                       [1, 2 * np.pi * f2],
                       mode='full')

    return bilinear(NUMs, DENs, fs)
   def A_weighting(self, fs):

       f1 = 20.598997
       f2 = 107.65265
       f3 = 737.86223
       f4 = 12194.217
       A1000 = 1.9997

       NUMs = [(2*pi * f4)**2 * (10**(A1000/20)), 0, 0, 0, 0]
       DENs = polymul([1, 4*pi * f4, (2*pi * f4)**2],
                   [1, 4*pi * f1, (2*pi * f1)**2])
       DENs = polymul(polymul(DENs, [1, 2*pi * f3]),
                                 [1, 2*pi * f2])

       return bilinear(NUMs, DENs, fs)
def a_weighting_coeffs_design(sample_rate):
    """Returns b and a coeff of a A-weighting filter.

    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.

    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.

    Examples
    --------
    >>> b, a = a_weighting_coeff_design(sample_rate)

    To Filter a signal use scipy lfilter:

    >>> from scipy.signal import lfilter
    >>> y = lfilter(b, a, x)

    See Also
    --------
    b_weighting_coeffs_design : B-Weighting coefficients.
    c_weighting_coeffs_design : C-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.
    scipy.lfilter : Filtering signal with `b` and `a` coefficients.
    """

    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997
    numerators = [(2*pi*f4)**2 * (10**(A1000 / 20.0)), 0., 0., 0., 0.];
    denominators = convolve(
        [1., +4*pi * f4, (2*pi * f4)**2],
        [1., +4*pi * f1, (2*pi * f1)**2]
    )
    denominators = convolve(
        convolve(denominators, [1., 2*pi * f3]),
        [1., 2*pi * f2]
    )
    return bilinear(numerators, denominators, sample_rate)
Esempio n. 11
0
def A_weighting(Fs):
    """Design of an A-weighting filter.
    
    B, A = A_weighting(Fs) designs a digital A-weighting filter for 
    sampling frequency Fs. Usage: y = lfilter(B, A, x).
    Warning: Fs should normally be higher than 20 kHz. For example, 
    Fs = 48000 yields a class 1-compliant filter.
    
    Originally a MATLAB script. Also included ASPEC, CDSGN, CSPEC.
    
    Author: Christophe Couvreur, Faculte Polytechnique de Mons (Belgium)
            [email protected]
    Last modification: Aug. 20, 1997, 10:00am.
    
    http://www.mathworks.com/matlabcentral/fileexchange/69
    http://replaygain.hydrogenaudio.org/mfiles/adsgn.m
    Translated from adsgn.m to PyLab 2009-07-14 [email protected]
    
    References: 
       [1] IEC/CD 1672: Electroacoustics-Sound Level Meters, Nov. 1996.
    
    """
    # Definition of analog A-weighting filter according to IEC/CD 1672.
    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997

    NUMs = [(2 * pi * f4)**2 * (10**(A1000 / 20)), 0, 0, 0, 0]
    DENs = convolve([1, +4 * pi * f4, (2 * pi * f4)**2],
                    [1, +4 * pi * f1, (2 * pi * f1)**2],
                    mode='full')
    DENs = convolve(convolve(DENs, [1, 2 * pi * f3], mode='full'),
                    [1, 2 * pi * f2],
                    mode='full')

    # Use the bilinear transformation to get the digital filter.
    # (Octave, MATLAB, and PyLab disagree about Fs vs 1/Fs)
    return bilinear(NUMs, DENs, Fs)


# You probably need to specify the axis. Importing a stereo sound file with scikits.audiolab needs axis = 0, for instance:
# y = lfilter(B, A, x, axis = 0)
def b_weighting_coeffs_design(sample_rate):
    """Returns `b` and `a` coeff of a B-weighting filter.

    B-Weighting is no longer described in DIN61672.

    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.

    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.

    Examples
    --------
    >>> b, a = b_weighting_coeff_design(sample_rate)

    To Filter a signal use :function: scipy.lfilter:

    >>> from scipy.signal import lfilter
    >>> y = lfilter(b, a, x)

    See Also
    --------
    a_weighting_coeffs_design : A-Weighting coefficients.
    c_weighting_coeffs_design : C-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.

    """

    f1 = 20.598997
    f2 = 158.5
    f4 = 12194.217
    B1000 = 0.17
    numerators = [(2*pi*f4)**2 * (10**(B1000 / 20)), 0, 0, 0];
    denominators = convolve(
        [1, +4*pi * f4, (2*pi * f4)**2],
        [1, +4*pi * f1, (2*pi * f1)**2]
    )
    denominators = convolve(denominators, [1, 2*pi * f2])
    return bilinear(numerators, denominators, sample_rate)
Esempio n. 13
0
def A_weighting(Fs):
    """Design of an A-weighting filter.
    
    B, A = A_weighting(Fs) designs a digital A-weighting filter for 
    sampling frequency Fs. Usage: y = lfilter(B, A, x).
    Warning: Fs should normally be higher than 20 kHz. For example, 
    Fs = 48000 yields a class 1-compliant filter.
    
    Originally a MATLAB script. Also included ASPEC, CDSGN, CSPEC.
    
    Author: Christophe Couvreur, Faculte Polytechnique de Mons (Belgium)
            [email protected]
    Last modification: Aug. 20, 1997, 10:00am.
    
    http://www.mathworks.com/matlabcentral/fileexchange/69
    http://replaygain.hydrogenaudio.org/mfiles/adsgn.m
    Translated from adsgn.m to PyLab 2009-07-14 [email protected]
    
    References: 
       [1] IEC/CD 1672: Electroacoustics-Sound Level Meters, Nov. 1996.
    
    """
    # Definition of analog A-weighting filter according to IEC/CD 1672.
    f1 = 20.598997
    f2 = 107.65265
    f3 = 737.86223
    f4 = 12194.217
    A1000 = 1.9997
    
    NUMs = [(2 * pi * f4)**2 * (10**(A1000/20)), 0, 0, 0, 0]
    DENs = convolve([1, +4 * pi * f4, (2 * pi * f4)**2], 
                    [1, +4 * pi * f1, (2 * pi * f1)**2], mode='full')
    DENs = convolve(convolve(DENs, [1, 2 * pi * f3], mode='full'), 
                                   [1, 2 * pi * f2], mode='full')
    
    # Use the bilinear transformation to get the digital filter.
    # (Octave, MATLAB, and PyLab disagree about Fs vs 1/Fs)
    return bilinear(NUMs, DENs, Fs)

# You probably need to specify the axis. Importing a stereo sound file with scikits.audiolab needs axis = 0, for instance:
# y = lfilter(B, A, x, axis = 0)
def c_weighting_coeffs_design(sample_rate):
    """Returns b and a coeff of a C-weighting filter.

    Parameters
    ----------
    sample_rate : scalar
        Sample rate of the signals that well be filtered.

    Returns
    -------
    b, a : ndarray
        Filter coefficients for a digital weighting filter.

    Examples
    --------
    b, a = c_weighting_coeffs_design(sample_rate)

    To Filter a signal use scipy lfilter:

    from scipy.signal import lfilter
    y = lfilter(b, a, x)

    See Also
    --------
    a_weighting_coeffs_design : A-Weighting coefficients.
    b_weighting_coeffs_design : B-Weighting coefficients.
    weight_signal : Apply a weighting filter to a signal.

    """

    f1 = 20.598997
    f4 = 12194.217
    C1000 = 0.0619
    numerators = [(2*pi * f4)**2 * (10**(C1000 / 20)), 0, 0]
    denominators = convolve(
        [1, +4*pi * f4, (2*pi * f4)**2],
        [1, +4*pi * f1, (2*pi * f1)**2]
    )
    return bilinear(numerators, denominators, sample_rate)