On Monday, 11 November 2024 16:34:16 EET Huang Wei wrote: > Hello everyone, > > For my program, in every 20 ms, I need to choose 60% of data in the stream > (I marked them with stream tags "start" and "stop"), then do FFT and plot, > and discard the following 40%. Is it possible to do all of this in gnuradio > with OOT blocks? > > I was thinking of keep M in N, but when I look at the block introduction, I > am worried that it may cause inaccuracy due to the changed data interval? > I am also looking at ZMQ sink, to send truncated data to an external Python > code for FFT, but my sample rate is quite high, I am afraid the python code > can't handle it. > > Please could you guide me in the right direction to do it properly? > > Thank you and best regards, > Wei
Hello Wei, I would think that the easiest way to achieve this is in a custom block, since you already have the stream tags to mark the samples. If you can afford the memory space, you could search for the start tag and once you encounter it, store all the following samples in a memory buffer. Once you encounter the stop tag, you take the buffer and perform the FFT on it then use the result wherever you need it. Then you can ignore any samples following the end tag until you encounter the next start tag. For performance reasons I would do this in a C++ block, but it might also be achievable in a Python block as well, since all the heavy compute would be offloaded to an external library like FFTW. HTH, Adrian