discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] How history() works in GR


From: Alberto Trentadue
Subject: [Discuss-gnuradio] How history() works in GR
Date: Mon, 28 Feb 2011 14:24:29 +0100 (CET)

Hello

I am trying to define a customised block and I would like to understand better 
how the history works.

I have opened the source of gr_moving_average_XX and I saw the following 
statement in the constructor:

@NAME@::@NAME@ (int length, @O_TYPE@ scale, int max_iter)
  : gr_sync_block ("@BASE_NAME@",
   gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
   gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
  d_length(length),
  d_scale(scale),
  d_max_iter(max_iter),
  d_new_length(length),
  d_new_scale(scale),
  d_updated(false)
{
  set_history(length);
}

So it seems to me that GR allocates a history buffer with "length" size.
But, later in the gr_moving_average_XX code I see the following cycle:

  for (int i = 0; i < num_iter; i++) {
    sum += in[i+d_length-1];
    out[i] = sum * d_scale;
    sum -= in[i];
  }
  
...which seems to show that there is at least a buffering of "length + 
num_iter" input items somewhere, and num_iter 
is >0 for sure.
This has confused me a bit on how history is implemented.

Thanks for any explanation.

Alberto


Supera i limiti: raddoppia la velocità da 10 a 20 Mega! Risparmia con Tutto 
Incluso: telefono + adsl 20 mega a soli 29,95 € al mese per due anni!SCONTO DI 
240 
EURO!http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso/?WT.mc_id=01fw



reply via email to

[Prev in Thread] Current Thread [Next in Thread]