3

I have a general work function for which I will use GNU Radio's history functionality. In the block's constructor, I call set_history( m ). I cast the input buffer in the standard way:

  const float *in = (const float *) input_items[0];

My question is wheere in[0] refers to in the buffer. It would make sense to me that noutput_items is the number of new items for the block to consume and ninput_items[0] refers to the total number of data in the buffer. So, in[noutput_items-1] is the last element of the array, in[0] is the start of the new items, and the in[-m] refers to the beginning of the history block. Thus, ninput_items[0] is greater than or equal to m + noutput_items.

I don't know if this assumption is true and would be pleased if someone knew how this works. The GNU Radio API is somewhat vague in this respect. Thanks in advance!

tweaksp
  • 601
  • 5
  • 14

2 Answers2

2

Tom Rondeau helped answer this question on the GNU Radio wiki. in[0] refers to the beginning of the history. In order to make in[0] refer the beginning of the new data, declare in this way:

const float *in = (const float *) &((const float*)input_items[0])[history()-1]; 
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
tweaksp
  • 601
  • 5
  • 14
1

Just for completeness of @Chris, set_history() refers to the number of items, just like the noutput_itmes parameter.

in[0] refers to the first item of the history. In order to skip the history and get the first new item this is the proper way:

const <TYPE> *in = (const <TYPE> *) &((const <TYPE>*)input_items[0])[(history()-1) * VEC_SIZE];

VEC_SIZE refers to the number of samples of type that was specified at the input signature.

So for example if the input signature of a block is

io_signature::make(1, 1, vec_len * sizeof(float))

each item is constructed from vec_len float numbers. The history can properly be skipped with:

const float *in_new = (const float *) &((const float*)input_items[0])[(history()-1) * vec_len];

Manos
  • 2,136
  • 17
  • 28