You have to copy your samples into get_inbuf() first. That's where FFTW expects the data. *dst is just a convenience variable to allow for less typing. Instead of:

memcpy(ofdm_fft.get_inbuf(), in, sizeof(gr_complex) * ofdm_fft_size);

You can use:

memcpy(dst, in, sizeof(gr_complex) * ofdm_fft_size);

Ron

On 12/23/21 10:42 AM, George Edwards wrote:
Hi Ron,

Sorry for bothering some more!
In Debugging it appears that dst is not pointing to the input data (input_items[0]), which we pointed to with pointer variable inat the start of the work(...)method
 (constgr_complex*in = (constgr_complex*) input_items[0];

Here is a snippet of my Debugging code and the values I see in ge_in = dst[i] while single stepping through the code are all zeros.
gr_complex * dst;                // copy from your code:
dst = ofdm_fft.get_inbuf();   //copy from your code
 //****** my debug code starts **********
gr_complex  ge_in;
for(int i = 0; i < 8; i++)          // I am inputting 8 samples
     {
           ge_in = dst[i];            // extracting the values in dst shows zero's
      }
// ******my debug code ends *********

It appears that setting dst = ofdm_fft.get_inbuf() is not pointing to the actual input samples values.

I did not see anywhere in your code where there is an explicit binding between in and get_inbuf().

I will appreciate it if you can help me here!
Thank you!
George

On Wed, Dec 15, 2021 at 12:32 AM Ron Economos <w...@comcast.net <mailto:w...@comcast.net>> wrote:

    FFT support is built in to GNU Radio with FFTW. Here's how it's
    done. First, define it in your foo_impl.h file. The options are
    fft_complex_fwd, fft_complex_rev, fft_real_fwd and fft_real_rev.

    https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.h#L25
    <https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.h#L25>

    https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.h#L41
    <https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.h#L41>

    Then initialize it in your foo_impl.cc constructor.

    https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.cc#L47
    <https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.cc#L47>

    Then execute it.

    
https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.cc#L175-L179
    
<https://github.com/drmpeg/gr-paint/blob/master/lib/paint_bc_impl.cc#L175-L179>

    You'll need to add the component in the top level CMakeLists.txt.

    https://github.com/drmpeg/gr-paint/blob/master/CMakeLists.txt#L78
    <https://github.com/drmpeg/gr-paint/blob/master/CMakeLists.txt#L78>

    And link with it in lib/CMakeLists.txt

    https://github.com/drmpeg/gr-paint/blob/master/lib/CMakeLists.txt#L25
    <https://github.com/drmpeg/gr-paint/blob/master/lib/CMakeLists.txt#L25>

    If you need a window, you can look at the block implementation
    file for details.

    https://github.com/gnuradio/gnuradio/blob/master/gr-fft/lib/fft_v_fftw.cc
    <https://github.com/gnuradio/gnuradio/blob/master/gr-fft/lib/fft_v_fftw.cc>

    Ron

    On 12/14/21 7:53 PM, George Edwards wrote:
     Dear GNURadio Community:

    I am writing a C++ OOT block where the signal processing requires
    the computation of both fft and ifft. Is there any Gnuradio C++
    functions for the fft and ifft? If not, is there any way to wrap
    in Python's libraries with these methods into C++ OOT?

    Thank you!

    Regards,
    George

Reply via email to