See fir_filter_blok.impl.cc for an example ...

forecast() does not include history. For a sync, interp or decim block,
forecast is not required at all.

history() should be the number of previous items required, without the (-1).

On Mon, Aug 28, 2023 at 5:08 AM Marco Menchise <marco.mench...@gmail.com>
wrote:

> Hi, I'm a gnuradio newbie.
>
> I'm trying to write a block that calculates output at time k based on
> three input samples: one at time k-N-1 (in the past), one at time k (the
> current sample) and one at k+M (in the future).
>
> I spent some hours struggling against "history" and forecast function.
>
> Here:
> https://lists.gnu.org/archive/html/discuss-gnuradio/2016-04/msg00520.html
> I found a good visualization of  the history concept. As I said, I also
> need to process "future" samples so I also investigated the "forecast"
> function.
>
> Here is what I understood:
>
> 1) history=N tells the scheduler to prepend N-1 "old" samples to the
> input_items buffer. The oldest prepended sample has relative index = 0, so
> the "current" buffer starts at index N-1.
>
> 2) The forecast function must return N-1 + noutput_items+ M, where M is
> the number of samples required in the future. Forecast *must* take into
> account history. Each general_work call is guaranteed to have *at least*
> N-1 + noutput_items+ M samples in input_items buffer.
>
> 3) I did some tests and noticed that the scheduler may pass to
> general_work *more* than N-1+noutput_items+M samples. Extra samples should
> be ignored by general_work. They will be passed again in the next call.
>
> 4) general_work must "consume" just noutput_items samples
>
> I tried to collect all those concepts in the attached figure where I used
> both absolute and relative indexes to mark samples. I assumed history=4 and
> M=2. The input_items in the first general_work call has at least 9 samples.
> I must process input samples from 103 to 106 (included) using samples from
> 100 to 108 (included) and I must generate 4 output_samples. In the next
> call I must process samples from 107 to 110 (included) and, again, I must
> generate 4 output samples. I must ignore "extra" samples in both cases.
>
> Is that correct? I'm I missing something?
>
> Thanks,
> Marco
>
>
>
>
>
> [image: gnuradio.drawio (1).png]
>

Reply via email to