Changeset 8329
- Timestamp:
- 05/08/08 19:44:41
- Files:
-
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/Makefile.am (modified) (2 diffs)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.cc (modified) (4 diffs)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.h (modified) (2 diffs)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.i (modified) (2 diffs)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc (copied) (copied from gnuradio/trunk/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h (copied) (copied from gnuradio/trunk/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h)
- gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_math.h (modified) (1 diff)
- gnuradio/branches/releases/3.1/gnuradio-core/src/python/gnuradio/gr/Makefile.am (modified) (1 diff)
- gnuradio/branches/releases/3.1/gnuradio-core/src/python/gnuradio/gr/qa_fft.py (copied) (copied from gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_fft.py)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/Makefile.am
r8267 r8329 71 71 gr_feval.cc \ 72 72 gr_fft_vcc.cc \ 73 gr_fft_vcc_fftw.cc \ 73 74 gr_fft_vfc.cc \ 74 75 gr_firdes.cc \ … … 202 203 gr_feval.h \ 203 204 gr_fft_vcc.h \ 205 gr_fft_vcc_fftw.h \ 204 206 gr_fft_vfc.h \ 205 207 gr_firdes.h \ gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.cc
r6044 r8329 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2004,2007 Free Software Foundation, Inc.3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 25 25 #endif 26 26 27 #include <gr_fft_vcc.h> 27 #include <gr_fft_vcc.h> // abstract class 28 #include <gr_fft_vcc_fftw.h> // concrete class 28 29 #include <gr_io_signature.h> 29 30 #include <gri_fft.h> … … 31 32 32 33 gr_fft_vcc_sptr 33 gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window, bool shift)34 gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> &window, bool shift) 34 35 { 35 return gr_ fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window, shift));36 return gr_make_fft_vcc_fftw(fft_size, forward, window, shift); 36 37 } 37 38 38 gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift) 39 : gr_sync_block ("fft_vcc", 39 gr_fft_vcc::gr_fft_vcc (const std::string &name, 40 int fft_size, bool forward, const std::vector<float> &window, 41 bool shift) 42 : gr_sync_block (name, 40 43 gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)), 41 44 gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))), 42 45 d_fft_size(fft_size), d_forward(forward), d_shift(shift) 43 46 { 44 d_fft = new gri_fft_complex (d_fft_size, forward);45 46 47 set_window(window); 47 48 48 } 49 49 50 50 gr_fft_vcc::~gr_fft_vcc () 51 51 { 52 delete d_fft;53 }54 55 int56 gr_fft_vcc::work (int noutput_items,57 gr_vector_const_void_star &input_items,58 gr_vector_void_star &output_items)59 {60 const gr_complex *in = (const gr_complex *) input_items[0];61 gr_complex *out = (gr_complex *) output_items[0];62 63 unsigned int input_data_size = input_signature()->sizeof_stream_item (0);64 unsigned int output_data_size = output_signature()->sizeof_stream_item (0);65 66 int count = 0;67 68 while (count++ < noutput_items){69 70 // copy input into optimally aligned buffer71 72 if (d_window.size()){73 gr_complex *dst = d_fft->get_inbuf();74 for (unsigned int i = 0; i < d_fft_size; i++) // apply window75 dst[i] = in[i] * d_window[i];76 }77 else {78 if(!d_forward && d_shift) { // apply an ifft shift on the data79 gr_complex *dst = d_fft->get_inbuf();80 unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half length of complex array81 memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len));82 memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len);83 }84 else {85 memcpy (d_fft->get_inbuf(), in, input_data_size);86 }87 }88 89 // compute the fft90 d_fft->execute ();91 92 // copy result to our output93 if(d_forward && d_shift) { // apply a fft shift on the data94 unsigned int len = (unsigned int)(ceil(d_fft_size/2.0));95 memcpy(&out[0], &d_fft->get_outbuf()[len], sizeof(gr_complex)*(d_fft_size - len));96 memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0], sizeof(gr_complex)*len);97 }98 else {99 memcpy (out, d_fft->get_outbuf (), output_data_size);100 }101 102 in += d_fft_size;103 out += d_fft_size;104 }105 106 return noutput_items;107 52 } 108 53 109 54 bool 110 gr_fft_vcc::set_window(const std::vector<float> window)55 gr_fft_vcc::set_window(const std::vector<float> &window) 111 56 { 112 57 if(window.size()==0 || window.size()==d_fft_size) { … … 117 62 return false; 118 63 } 119 120 /*121 fftshift122 123 for(i=0; i < ceil(d_occupied_carriers/2.0); i++) {124 unsigned int k=ceil(d_occupied_carriers/2.0);125 out[i] = gr_complex(-1+2*in[i+k],0);126 }127 for(; i < d_vlen - ceil(d_occupied_carriers/2.0); i++) {128 out[i]=gr_complex(0,0);129 }130 for(unsigned int j=0;i<d_vlen;i++,j++) {131 out[i]= gr_complex((-1+2*in[j]),0);132 }133 */gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.h
r7517 r8329 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2004,2007 Free Software Foundation, Inc.3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 26 26 #include <gr_sync_block.h> 27 27 28 class gri_fft_complex;29 30 28 class gr_fft_vcc; 31 29 typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr; 32 30 33 31 gr_fft_vcc_sptr 34 gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);32 gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false); 35 33 36 34 /*! 37 35 * \brief Compute forward or reverse FFT. complex vector in / complex vector out. 38 36 * \ingroup dft 37 * 38 * Abstract base class 39 39 */ 40 41 40 class gr_fft_vcc : public gr_sync_block 42 41 { 42 protected: 43 43 friend gr_fft_vcc_sptr 44 gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift);44 gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift); 45 45 46 unsigned int d_fft_size;46 unsigned int d_fft_size; 47 47 std::vector<float> d_window; 48 gri_fft_complex *d_fft;49 48 bool d_forward; 50 49 bool d_shift; 51 50 52 gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift); 51 gr_fft_vcc (const std::string &name, int fft_size, bool forward, 52 const std::vector<float> &window, bool shift); 53 53 54 54 public: 55 55 ~gr_fft_vcc (); 56 56 57 int work (int noutput_items, 58 gr_vector_const_void_star &input_items, 59 gr_vector_void_star &output_items); 60 bool set_window(const std::vector<float> window); 57 bool set_window(const std::vector<float> &window); 61 58 }; 62 59 63 64 60 #endif /* INCLUDED_GR_FFT_VCC_H */ gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_fft_vcc.i
r6044 r8329 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2004,2007 Free Software Foundation, Inc.3 * Copyright 2004,2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 29 29 { 30 30 protected: 31 gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift);31 gr_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift); 32 32 33 33 public: 34 bool set_window(const std::vector<float> window);34 bool set_window(const std::vector<float> &window); 35 35 }; gnuradio/branches/releases/3.1/gnuradio-core/src/lib/general/gr_math.h
r7654 r8329 29 29 30 30 #include <gr_complex.h> 31 32 static inline bool 33 gr_is_power_of_2(long x) 34 { 35 return x != 0 && (x & (x-1)) == 0; 36 } 31 37 32 38 long gr_gcd (long m, long n); gnuradio/branches/releases/3.1/gnuradio-core/src/python/gnuradio/gr/Makefile.am
r7808 r8329 62 62 qa_diff_phasor_cc.py \ 63 63 qa_feval.py \ 64 qa_fft.py \ 64 65 qa_fft_filter.py \ 65 66 qa_filter_delay_fc.py \
