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);
        }
Пример #2
0
        public OutbandPowerSpectrumSignal(int nsize)
        {
            this.block_size = nsize;

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

            filt_design.makewindow(WindowType_e.BLACKMANHARRIS_WINDOW,
                                   nsize,
                                   ref window);

            this.ps_cpx  = new CPX[nsize * 2];
            this.tmp_cpx = new CPX[nsize * 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(nsize * 2,
                                      h_temp.AddrOfPinnedObject(),
                                      h_ps.AddrOfPinnedObject(),
                                      FFTW.fftw_direction.Forward,
                                      FFTW.fftw_flags.Measure);
        }
Пример #3
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);
        }
Пример #4
0
 public void Exit()         // destructor
 {
     FFTW.destroy_plan(plan_fwd_main);
     FFTW.destroy_plan(plan_rev_main);
     h_cpx.Free();
     h_tmp1.Free();
     h_tmp2.Free();
     h_tmp3.Free();
 }
Пример #5
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));
            }
        }
Пример #6
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);
        }
Пример #7
0
 internal void DoFFTReverseMain()
 {
     FFTW.execute(plan_rev_main);
 }
Пример #8
0
 internal void DoFFTForwardMain()
 {
     FFTW.execute(plan_fwd_main);
 }
Пример #9
0
 public void Exit()
 {
     FFTW.destroy_plan(plan_fwd_filter);
     h_filter.Free();
     h_temp.Free();
 }
Пример #10
0
 internal void DoFFTForwardFilter()
 {
     FFTW.execute(plan_fwd_filter);
 }
 private void DoFFTForwardPS()
 {
     FFTW.execute(plan_fwd_ps);
 }
 public void Exit()
 {
     FFTW.destroy_plan(plan_fwd_ps);
     h_ps.Free();
     h_temp.Free();
 }