Class: AudioStream::Fx::LowPassFilter
- Inherits:
-
BiquadFilter
- Object
- BiquadFilter
- AudioStream::Fx::LowPassFilter
- Defined in:
- lib/audio_stream/fx/low_pass_filter.rb
Constant Summary
Constants inherited from BiquadFilter
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BiquadFilter
#initialize, #plot, #plot_data, #process
Constructor Details
This class inherits a constructor from AudioStream::Fx::BiquadFilter
Class Method Details
.create(soundinfo, freq:, q: DEFAULT_Q) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/audio_stream/fx/low_pass_filter.rb', line 27 def self.create(soundinfo, freq:, q: DEFAULT_Q) filter = new(soundinfo) filter.update_coef(freq: freq, q: q) filter end |
Instance Method Details
#update_coef(freq:, q:) ⇒ Object
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 |