Module: Radio::Filter::Agc::Float
- Defined in:
- lib/radio/filters/agc.rb
Instance Method Summary collapse
Instance Method Details
#call(data) {|data.collect do |v| out = @gain * v abs_delta = out.abs - @reference if abs_delta.abs > @gain rate = @attack out = -1.0 if out < -1.0 out = 1.0 if out > 1.0 else rate = @decay if out < -1.0 out = -1.0 rate *= 10 end if out > 1.0 out = 1.0 rate *= 10 end end @gain -= abs_delta * rate out end| ... } ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/radio/filters/agc.rb', line 37 def call data yield(data.collect do |v| out = @gain * v abs_delta = out.abs - @reference if abs_delta.abs > @gain rate = @attack out = -1.0 if out < -1.0 out = 1.0 if out > 1.0 else rate = @decay if out < -1.0 out = -1.0 rate *= 10 end if out > 1.0 out = 1.0 rate *= 10 end end @gain -= abs_delta * rate out end) end |