Example #1
0
        public AveragingNoiseBlanker(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.average_magnitude = 1f;
        }
        public PowerSpectrumSignal(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.sample_rate  = s.DSPSampleRate;
            this.block_size   = s.DSPBlockSize;
            this.strobe_count = (int)this.sample_rate / (this.block_size * this.rate);

            this.window      = new float[s.DSPBlockSize];
            this.ps_results  = new float[s.DSPBlockSize * 2];
            this.ps_average  = new float[s.DSPBlockSize * 2];
            this.filt_design = new FilterDesigner();

            filt_design.makewindow(WindowType_e.BLACKMANHARRIS_WINDOW,
                                   s.DSPBlockSize,
                                   ref window);

            this.ps_cpx  = new CPX[s.DSPBlockSize * 2];
            this.tmp_cpx = new CPX[s.DSPBlockSize * 2];

            h_ps   = GCHandle.Alloc(ps_cpx, GCHandleType.Pinned);
            h_temp = GCHandle.Alloc(tmp_cpx, GCHandleType.Pinned);

            // in: tmp_cpx_1 out: ps_cpx
            plan_fwd_ps = FFTW.dft_1d(s.DSPBlockSize * 2,
                                      h_temp.AddrOfPinnedObject(),
                                      h_ps.AddrOfPinnedObject(),
                                      FFTW.fftw_direction.Forward,
                                      FFTW.fftw_flags.Measure);
        }
Example #3
0
 public DCCorrector(ref DSPBuffer dsp_buffer_obj)
 {
     this.d              = dsp_buffer_obj;
     this.s              = d.State;
     this.smooth         = 0.001f;
     this.oneminussmooth = 1.0f - smooth;
 }
Example #4
0
        public DAgc(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            ComputeAttackTime(newattack);
            //this.attack = (float)(1.0f - Math.Exp(-1000.0 / (s.DSPSampleRate * newattack)));
            //this.one_m_attack = (float)Math.Exp(-1000.0 / (s.DSPSampleRate * newattack));
            //this.sndx = (int)(s.DSPSampleRate * (newattack / 333.33f));

            ComputeDecayTime(newdecay);
            //this.decay = (float)(1.0f - Math.Exp(-1000.0 / (s.DSPSampleRate * newdecay)));
            //this.one_m_decay = (float)Math.Exp(-1000.0 / (s.DSPSampleRate * newdecay));

            this.hangindex  = this.indx = 0;
            this.hangtime   = newhangtime * 0.001f;
            this.hangthresh = 1.0f;
            this.gain_fix   = newfixedgain;

            this.slope      = newslope;
            this.gain_top   = newmaxgain;
            this.hangthresh = this.gain_bottom = newmingain;
            this.gain_old   = this.gain_now = newcurrentgain;

            this.gain_limit = newlimit;

            this.mask  = 2 * s.DSPBlockSize;
            this.G     = new CPX[this.mask];
            this.mask -= 1;
        }
Example #5
0
        public DAgc(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            fastattacktime = 0.2F;
            fastdecaytime  = 3.0F;
            ComputeFastAttackTime(fastattacktime);
            ComputeFastDecayTime(fastdecaytime);

            ComputeAttackTime(newattack);
            ComputeDecayTime(newdecay);
            ComputeHangDecayTime(hangdecaytime);

            this.hangindex  = this.indx = 0;
            this.hangtime   = newhangtime * 0.001f;
            this.hangthresh = 1.0f;
            this.gain_fix   = newfixedgain;

            this.slope      = newslope;
            this.gain_top   = newmaxgain;
            this.hangthresh = this.gain_bottom = newmingain;
            this.fast_now   = this.gain_old = this.gain_now = newcurrentgain;

            this.gain_limit = newlimit;

            this.mask  = 2 * s.DSPBlockSize;
            this.G     = new CPX[this.mask];
            this.mask -= 1;

            fasthang     = 0;
            fasthangtime = 0.1F * hangtime;
        }
Example #6
0
        public OutbandPowerSpectrumSignal(ref DSPBuffer dsp_buffer_obj, WindowType_e filterType)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.block_size = s.DSPBlockSize;

            this.window      = new float[s.DSPBlockSize];
            this.ps_results  = new float[s.DSPBlockSize * 2];
            this.ps_average  = new float[s.DSPBlockSize * 2];
            this.filt_design = new FilterDesigner();

            filt_design.makewindow(filterType,
                                   s.DSPBlockSize,
                                   ref window);

            this.ps_cpx  = new CPX[s.DSPBlockSize * 2];
            this.tmp_cpx = new CPX[s.DSPBlockSize * 2];

            h_ps   = GCHandle.Alloc(ps_cpx, GCHandleType.Pinned);
            h_temp = GCHandle.Alloc(tmp_cpx, GCHandleType.Pinned);

            // in: tmp_cpx_1 out: ps_cpx
            plan_fwd_ps = FFTW.dft_1d(s.DSPBlockSize * 2,
                                      h_temp.AddrOfPinnedObject(),
                                      h_ps.AddrOfPinnedObject(),
                                      FFTW.fftw_direction.Forward,
                                      FFTW.fftw_flags.Measure);
        }
Example #7
0
        public SignalMeter(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.sample_rate = s.DSPSampleRate;
            this.block_size  = s.DSPBlockSize;

            this.strobe_count = (int)this.sample_rate / (this.block_size * this.rate);
        }
Example #8
0
        public InterferenceFilter(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.lms_size         = 128;        // 45
            this.mask             = this.lms_size - 1;
            this.delay_line       = new float[128 /*this.lms_size */];
            this.coefficients     = new float[128];
            this.delay_line_index = 0;
        }
Example #9
0
        public InterferenceFilter(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.lms_size         = 128;    // MUST  be a power of 2...
            this.mask             = this.lms_size - 1;
            this.delay_line       = new float[this.lms_size];
            this.coefficients     = new float[this.lms_size];
            this.kTable           = new int[this.lms_size, this.lms_size];
            this.delay_line_index = 0;
        }
Example #10
0
        public PLL(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.pll_internal_state.phase        = 0.0F;
            this.pll_internal_state.delay_real   = 0F;
            this.pll_internal_state.delay_imag   = 1F;
            this.pll_internal_state.lockcurrent  = 0.5F;
            this.pll_internal_state.lockprevious = 1F;
            this.pll_internal_state.dc           = 0F;
            this.pll_internal_state.afc          = 0F;
        }
Example #11
0
        public Oscillator(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.frequencyTone = this.LOFrequency / s.DSPSampleRate;
            this.magnitudeTone = (float)this.LOMagnitude;
            this.stepTone      = this.LOFrequency * this.TWO_PI;
            this.phaseTone     = this.LOPhase;
            this.CosN          = 0;
            this.SinN          = 0;

            this.temp = new CPX[this.s.PowerSpectrumBlockSize];
        }
Example #12
0
        public DSPBuffer(DSPState state)
        {
            this.State = state;

            size = this.State.DSPBlockSize * 2;

            audio_ring_buffer = new RingBuffer(size * 8);

            cpx       = new CPX[size];
            tmp_cpx_1 = new CPX[size];
            tmp_cpx_2 = new CPX[size];
            tmp_cpx_3 = new CPX[size];
            dec_cpx   = new CPX[size / 2];

            halfsize    = size / 2;
            leftside    = 0;
            rightside   = halfsize;
            scalefactor = (float)1.0f / size;

            h_cpx  = GCHandle.Alloc(cpx, GCHandleType.Pinned);
            h_tmp1 = GCHandle.Alloc(tmp_cpx_1, GCHandleType.Pinned);
            h_tmp2 = GCHandle.Alloc(tmp_cpx_2, GCHandleType.Pinned);
            h_tmp3 = GCHandle.Alloc(tmp_cpx_3, GCHandleType.Pinned);

            // in: cpx out: tmp_cpx_1
            plan_fwd_main = FFTW.dft_1d(size,
                                        h_cpx.AddrOfPinnedObject(),
                                        h_tmp1.AddrOfPinnedObject(),
                                        FFTW.fftw_direction.Forward,
                                        FFTW.fftw_flags.Measure);

            // in: tmp_cpx_2 out: tmp_cpx_3
            plan_rev_main = FFTW.dft_1d(size,
                                        h_tmp2.AddrOfPinnedObject(),
                                        h_tmp3.AddrOfPinnedObject(),
                                        FFTW.fftw_direction.Backward,
                                        FFTW.fftw_flags.Measure);

            this.stage = new int[State.DSPBlockSize];
            this.index = 0;

            for (int i = 0; i < State.OutputRateDivisor; i++)
            {
                stage[i] = (int)((double)State.DSPBlockSize * ((double)i / (double)State.OutputRateDivisor));
            }
        }
Example #13
0
        public Filter(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            this.ovlp_cpx        = new CPX[s.DSPBlockSize];
            this.filter_cpx      = new CPX[s.DSPBlockSize * 2];
            this.tmp_cpx         = new CPX[s.DSPBlockSize * 2];
            this.filter_designer = new FilterDesigner();

            h_filter = GCHandle.Alloc(filter_cpx, GCHandleType.Pinned);
            h_temp   = GCHandle.Alloc(tmp_cpx, GCHandleType.Pinned);

            // in: tmp_cpx out: filter_cpx
            plan_fwd_filter = FFTW.dft_1d(s.DSPBlockSize * 2,
                                          h_temp.AddrOfPinnedObject(),
                                          h_filter.AddrOfPinnedObject(),
                                          FFTW.fftw_direction.Forward,
                                          FFTW.fftw_flags.Measure);
        }
Example #14
0
        public WCPAGC(ref DSPBuffer dsp_buffer_obj)
        {
            this.d = dsp_buffer_obj;
            this.s = d.State;

            //initialization
            InitWcpAGC();

            //defaults
            agc_mode             = AGCType_e.agcLong;
            sample_rate          = 48000;
            fixed_gain           = 1000;
            n_tau                = 4;
            tau_attack           = 0.001;
            tau_decay            = 0.250;
            tau_fast_decay       = 0.005;
            tau_fast_backaverage = 0.250;
            pop_ratio            = 5;
            out_targ             = 1.0;
            var_gain             = 1.0;
            max_gain             = 100000.0;
            tau_hang_decay       = 0.100;

#if false
            max_input = 1.0;
#else
            // Warren NR0V reports that this change needs to be made in order for things to be
            // in the right position on the screen and other factors.
            max_input = 500.0;
#endif

            hang_thresh       = 0.01;
            hangtime          = 0.250;
            tau_hang_backmult = 0.500;

            //setup calculated variables
            LoadWcpAGC();
        }
Example #15
0
 public Squelch(ref DSPBuffer dsp_buffer_obj)
 {
     this.d = dsp_buffer_obj;
     this.s = d.State;
 }
Example #16
0
        public Receiver()
        {
            DSPState state = new DSPState();

//            state.ServerConfigObject = sc;
//            state.DSPBlockSize = sc.DSPBlockSize;
//            state.DSPSampleRate = sc.DSPSampleRate;
//            state.PowerSpectrumBlockSize = sc.SpecBlockSize;

            rxbuffer = new DSPBuffer(state);

            dcc = new DCCorrector(ref rxbuffer);

            // Filter
            filter = new Filter(ref rxbuffer);

            // Local Oscillator (channel)
            local_osc = new Oscillator(ref rxbuffer);
            local_osc.LocalOscillatorOn = true;

            // Local Oscillator (channel)
            spec_local_osc = new Oscillator(ref rxbuffer);
            spec_local_osc.LocalOscillatorOn = true;

            // AGC
            //agc = new DAgc(ref rxbuffer);
            agc = new WCPAGC(ref rxbuffer);

            // Block Noise Blanker
            block_noise_blanker = new BlockNoiseBlanker(ref rxbuffer);
            bnb_spec            = new BlockNoiseBlanker(ref rxbuffer);

            // Average Noise Blanker
            ave_noise_blanker = new AveragingNoiseBlanker(ref rxbuffer);
            anb_spec          = new AveragingNoiseBlanker(ref rxbuffer);

            // Squelch
            squelch = new Squelch(ref rxbuffer);

            // Signal Metering
            meter = new SignalMeter(ref rxbuffer);

            // Power Spectrum
            power_spectrum = new PowerSpectrumSignal(ref rxbuffer);

            // PLL
            pll = new PLL(ref rxbuffer);

            // Noise Filter
            noise_filter = new NoiseFilter(ref rxbuffer);

            // Interference Filter
            interference_filter = new InterferenceFilter(ref rxbuffer);

            // Output
            output_mode = new Output(ref rxbuffer);

            cfir = new LoadableFilter(state.SpectrumAquireBlockSize, 64);
            cfir.LoadFilter(new FilterCoeffSet(64).GetFilterCoeffSet());

//            ops = new OutbandPowerSpectrumSignal(state.PowerSpectrumBlockSize);
        }
Example #17
0
 public Output(ref DSPBuffer dsp_buffer_obj)
 {
     this.d = dsp_buffer_obj;
     this.s = d.State;
 }
Example #18
0
 public AGC(ref DSPBuffer dsp_buffer_obj)
 {
     this.d = dsp_buffer_obj;
     this.s = d.State;
 }