Module: Radio::Filter::SetupFir
- Included in:
- Fir, InterpolateFir, Mix, MixDecimateFir, MixFir, MixInterpolateFir
- Defined in:
- lib/radio/filters/fir.rb
Instance Method Summary collapse
- #decimation_fir=(coef) ⇒ Object (also: #fir=)
- #decimation_mix=(mix) ⇒ Object (also: #mix=)
- #interpolation_fir=(coef) ⇒ Object
- #interpolation_mix=(mix) ⇒ Object
Instance Method Details
#decimation_fir=(coef) ⇒ Object Also known as: fir=
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/radio/filters/fir.rb', line 56 def decimation_fir= coef if @decimation_fir_orig raise "can't grow filter" if coef.size > @decimation_fir_size else @decimation_fir_pos = 0 @decimation_fir_size = coef.size @decimation_buf = NArray.scomplex @decimation_fir_size # decimation allows fractions for digital work if Float === @decimation_size @decimation_pos = 0.0 else @decimation_pos = 0 end end @decimation_fir_orig = coef setup_decimation end |
#decimation_mix=(mix) ⇒ Object Also known as: mix=
47 48 49 50 51 52 53 |
# File 'lib/radio/filters/fir.rb', line 47 def decimation_mix= mix @decimation_mix = mix @decimation_fir_pos = 0 # sync to mixer @decimation_phase, @decimation_inc = new_mixer @decimation_mix, @decimation_size setup_decimation if @decimation_fir_orig end |
#interpolation_fir=(coef) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/radio/filters/fir.rb', line 29 def interpolation_fir= coef # expand interpolation filter for matrix by padding with 0s remainder = coef.size % @interpolation_size if remainder > 0 coef = coef.to_a + [0]*(@interpolation_size-remainder) end if @interpolation_fir_orig raise "can't grow filter" if coef.size > @interpolation_fir_size else @interpolation_fir_pos = 0 @interpolation_fir_size = coef.size / @interpolation_size @interpolation_buf_f = NArray.sfloat @interpolation_fir_size @interpolation_buf_c = NArray.scomplex @interpolation_fir_size end @interpolation_fir_orig = coef setup_interpolation end |
#interpolation_mix=(mix) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/radio/filters/fir.rb', line 21 def interpolation_mix= mix @interpolation_mix = mix @interpolation_fir_pos = 0 # sync to mixer @interpolation_phase, @interpolation_inc = new_mixer @interpolation_mix, @interpolation_size setup_interpolation if @interpolation_fir_orig end |