Module: Radio::Filter::MixFir

Includes:
SetupFir
Defined in:
lib/radio/filters/fir.rb

Instance Method Summary collapse

Methods included from SetupFir

#decimation_fir=, #decimation_mix=, #interpolation_fir=, #interpolation_mix=

Instance Method Details

#call(data, &block) ⇒ Object



208
209
210
# File 'lib/radio/filters/fir.rb', line 208

def call data, &block
  call! data.dup, &block
end

#call!(data) {|data| ... } ⇒ Object

Yields:

  • (data)


211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/radio/filters/fir.rb', line 211

def call! data
  @decimation_phase /= @decimation_phase.abs
  data.collect! do |value|
    @decimation_buf[@decimation_fir_pos] = value
    @decimation_fir_pos += 1
    @decimation_fir_pos = 0 if @decimation_fir_pos == @decimation_fir_size
    @decimation_phase *= @decimation_inc
    value = @decimation_fir_coef[@decimation_fir_pos].mul_accum @decimation_buf, 0
    value[0] * @decimation_phase
  end
  yield data
end