Sha256: b1bfadb0f9bab171e3f9c79f3fcab637d2825ca39294f6cfc13c6a209ba05736
Contents?: true
Size: 882 Bytes
Versions: 3
Compression:
Stored size: 882 Bytes
Contents
module SPCore class CookbookHighpassFilter < BiquadFilter def initialize sample_rate super(sample_rate) end def set_critical_freq_and_bw critical_freq, bandwidth @critical_freq = critical_freq @bandwidth = bandwidth # setup variables omega = 2.0 * Math::PI * @critical_freq / @sample_rate sn = Math::sin(omega) cs = Math::cos(omega) alpha = sn * Math::sinh(BiquadFilter::LN_2 / 2.0 * @bandwidth * omega / sn) b0 = (1.0 + cs) / 2.0 b1 =-(1.0 + cs) b2 = (1.0 + cs) / 2.0 a0 = 1.0 + alpha a1 = -2.0 * cs a2 = 1.0 - alpha # precompute the coefficients @biquad.b0 = b0 / a0 @biquad.b1 = b1 / a0 @biquad.b2 = b2 / a0 @biquad.a0 = a0 / a0 @biquad.a1 = a1 / a0 @biquad.a2 = a2 / a0 ## zero initial samples #@biquad.x1 = @biquad.x2 = 0 #@biquad.y1 = @biquad.y2 = 0 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spcore-0.1.2 | lib/spcore/lib/cookbook_highpass_filter.rb |
spcore-0.1.1 | lib/spcore/lib/cookbook_highpass_filter.rb |
spcore-0.1.0 | lib/spcore/lib/cookbook_highpass_filter.rb |