Comments in-line.
Ron
On 12/16/21 12:47 PM, George Edwards wrote:
Hi Ron,
Thanks again for sending the links and annotating the lines of
interest. I have looked through links and have some questions:
Q1. The lib/CMakeList.txt file I can identify easily, but I am not
sure which is the top level CMakeList.txt file. There are
CMakeList.txt files in directories "apps" and "grc" in my project
directory and I am not sure which is considered the top level. I do
not know if you can help me here (thing is, in my project the contents
of these CMakefileList.txt files are small and do not mimic that in
the link you sent, so I have no clue).
Let's say you have an OOT in your home directory.
~/gr-something
The top level CMakeLists.txt is in ~/gr-something.
Q2. I am reading in a fixed size vector of floats to compute the fft
and output a vector of fft values (complex) the same size as the block
of input, so I assumed the OOT block should be a "sync" block, right?
Yes. If you want to use vectors on your input and output pins, change
the signature to (where vlength is your vector size):
gr::io_signature::make(1, 1, sizeof(input_type) * vlength),
gr::io_signature::make(1, 1, sizeof(output_type) * vlength)),
Then in the block .yml file, use the vlen tag.
inputs:
- domain: stream
dtype: complex
vlen: ${vlength}
outputs:
- domain: stream
dtype: complex
vlen: ${vlength}
Note that when you use vectors, noutput_items will be the number of
vectors, not the number of items in each vector.
Q3. Assuming the input vector comes in on the variable "in" and the
output vector is on the variable "out" how do I taylor the expression
in the link which I copied below to compute the fft and pass it to the
output (plus, is volk_32fc_s32fc_multiply_32fc(...) a function in the
fft computation module?):
df0555eb-9839-457b-ac3d-0a4c9d17c662.png
I was using an IFFT in that example, and it's almost always required to
normalize the output. So that's what the volk_32fc_s32fc_multiply_32fc()
was for. Here's the code for just a simple in to out IFFT. Also, the
variable names don't have to be "ofdm_fft". You can use something more
descriptive.
gr_complex* dst;
dst = ofdm_fft.get_inbuf();
memcpy(&dst[ofdm_fft_size / 2], &in[0], sizeof(gr_complex) *
ofdm_fft_size / 2);
memcpy(&dst[0], &in[ofdm_fft_size / 2], sizeof(gr_complex) *
ofdm_fft_size / 2);
ofdm_fft.execute();
memcpy(&out[0], ofdm_fft.get_outbuf(), sizeof(gr_complex) *
ofdm_fft_size);
Note that for a forward FFT, you have to do the shift /after/ the FFT.
Also, the example is complex in and complex out.
Thank you very much!
George
On Wed, Dec 15, 2021 at 12:32 AM Ron Economos <[email protected]
<mailto:[email protected]>> 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