Dim B0(4), B1(4), A0(4), A1(4), Reg(4), Out, Temp, Reg
As Double
Private Sub Form_Load()
'Step response
of an RIAA equalization filter
'Sample rate = 192 kHz, coefficients
for an impulse invariant transformation
'Refer to http://beis.de/Elektronik/Filter/AnaDigFilt/1stOrderDigFilt.html#RIAA
'Stage 1
B0(1) = 1
B1(1) = -1
A0(1) = 1
A1(1) = -0.99934544
'Stage 2
B0(2) = 0.0016378
B1(2) = 0
A0(2) = 1
A1(2) = -0.99836216
'Stage 3
B0(3) = 61.056
B1(3) = -60.056
A0(3) = 1
A1(3) = 0
'Stage 4
B0(4) = 0.0694444
B1(4) = 0
A0(4) = 1
A1(4) = -0.9305555
'Simulation runs
60 ms = 192 * 60 samples (192 samples per ms)
For T = 0 To 60 '60 ms
Debug.Print T; 'ms number
Debug.Print Out 'Filter output value
For I = 1 To
192 '192 samples
per ms
Out
= 1 'Filter input value for an initial step = 1
'The filter process for one sample:
For
K = 1 To 4 '4 stages
Temp
= Out - Reg(K) * A1(K) 'This input = previous output
Out
= B0(K) * Temp + B1(K) * Reg(K) 'This
output = next input
Reg(K)
= Temp
Next
K
Next I
Next T
Debug.Print "-------------------------"
End
End Sub |