constant Coefficients [4] {
value: [ 0.25, 0.25, 0.25, 0.25 ]
meta: 'Coefficients of FIR filter'
}
signal Taps [4] {
default: 0.0
rate: AudioRate
reset: MasterReset
meta: 'Taps holds a single sample Delayed value'
}
AudioIn [1]
>> FixedDelay (
samples: [ 0, 1, 2, 3 ]
default: 0.0
reset: off
bypass: off
)
>> Taps;
Taps * Coefficients
>> Mix ()
>> AudioOut [1:2];
AudioIn[1] >> FixedDelay ( samples: 0 ) >> Taps[1];
AudioIn[1] >> FixedDelay ( samples: 1 ) >> Taps[2];
AudioIn[1] >> FixedDelay ( samples: 2 ) >> Taps[3];
AudioIn[1] >> FixedDelay ( samples: 3 ) >> Taps[4];
signal Intermediate [4] {
default: 0.0
rate: AudioRate
reset: MasterReset
meta: 'Holds intermediate values of Taps * Coefs'
}
signal Sum {
default: 0.0
rate: AudioRate
reset: MasterReset
meta: 'Holds Sum of Taps * Coefs'
}
Taps[1] * Coefficients[1] >> Intermediate[1];
Taps[2] * Coefficients[2] >> Intermediate[2];
Taps[3] * Coefficients[3] >> Intermediate[3];
Taps[4] * Coefficients[4] >> Intermediate[4];
Intermediate[1] + Intermediate[2] + Intermediate[3] + Intermediate[4] >> Sum;
Sum >> AudioOut[1:2];
module FIR {
input: Input
output: Output
propertyName: [ 'length', 'coefficients', 'reset' ]
propertyDirection: in
propertyBlock: [
constant Length { value: 2 },
constant Coefficients [Length] { value: [ 0.5, 0.5 ] },
trigger Reset {}
]
internalBlock: [
signal Input {
default: 0.0
rate: streamRate
reset: Reset
},
signal Output {
default: 0.0
rate: streamRate
reset: Reset
},
signal DelayValues [Length] {
default: 0
rate: none
reset: none
},
signal Taps [Length] {
default: 0.0
rate: none
reset: Reset
}
]
streams: [
Counter (
startValue: 0
)
>> Table (
size: Length
rate: Length
)
>> DelayValues;
,
Input
>> FixedDelay (
samples: DelayValues
default: 0.0
reset: Reset
bypass: off
)
>> Taps;
,
Taps * Coefficients
>> Mix ()
>> Output;
]
meta: 'Generic Real FIR Filter'
}
constant FIR_Length {
value: 8
meta: 'Length of FIR Filter'
}
constant FIR_Coef [FIR_Length] {
value: 1.0 / FIR_Length
meta: 'FIR Filter Coefficients'
}
AudioIn[1]
>> FIR (
length: FIR_Length
coefficients: FIR_Coef
reset: off
)
>> AudioOut[1:2];