5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/audio_stream/fx/low_pass_filter.rb', line 5
def update_coef(freq:, q:)
freq = Rate.freq(freq)
omega = freq.sample_phase(@soundinfo)
alpha = Math.sin(omega) / (2.0 * q)
a0 = 1.0 + alpha
a1 = -2.0 * Math.cos(omega)
a2 = 1.0 - alpha
b0 = (1.0 - Math.cos(omega)) / 2.0
b1 = 1.0 - Math.cos(omega)
b2 = (1.0 - Math.cos(omega)) / 2.0
@coef = Vdsp::Biquad::Coefficient.new(b0/a0, b1/a0, b2/a0, a1/a0, a2/a0)
@biquads.each {|biquad|
biquad.coefficients = @coef
}
end
|