Class: PREFilter

Inherits:
IIRFilter show all
Defined in:
lib/Loudness/PreFilter/PREFilter.rb

Overview

PRE filter implementation

Instance Method Summary collapse

Methods inherited from IIRFilter

#FilterSample, #SetCoefs

Constructor Details

#initialize(fs) ⇒ PREFilter

Initialize PRE Filter implementation

Parameters:

  • fs (int)

    sets the sampleing frecuency. It is used to compute the filter coeficients according to the PRE Filter definition in ITU-R BS.1770



10
11
12
13
14
# File 'lib/Loudness/PreFilter/PREFilter.rb', line 10

def initialize(fs)
  super 2 
  
  SetFreqSampling(fs)
end

Instance Method Details

#InfoString

Gets filter information

Returns:

  • (String)

    filter information



39
40
41
# File 'lib/Loudness/PreFilter/PREFilter.rb', line 39

def Info
  return "PRE Filter--------\nFs = #{@fs} Hz\n#{super}\n------------------\n"
end

#SetFreqSampling(fs) ⇒ Object

Sets PRE Filter sampleing frecuency

Parameters:

  • fs (int)

    sets the sampleing frecuency. It is used to compute the filter coeficients according to the PRE Filter definition in ITU-R BS.1770



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Loudness/PreFilter/PREFilter.rb', line 18

def SetFreqSampling (fs) 
  @fs = fs
  
  #PRE FILTER - Order 2 = 3coefs
  #Coefs Fs = 48KHz (ITU 1770 published coefs for fs = 48KHz)
  mACoefs = [1.0, -1.69065929318241, 0.73248077421585]
  mBCoefs = [1.53512485958697, -2.69169618940638, 1.19839281085285]

  if (@fs != 48000)
    #Parameters of second order HF shelvoing filter
    nGdb = 4      #Gain in DB
    dFc = 1650    #Center freq

    mBCoefs , mACoefs = CalcCoefs fs, nGdb, dFc
  end

  SetCoefs mBCoefs,mACoefs
end