PROBLEM: Understanding gr_block's implementation

These are some of the input parameters of gr_block::general_work() :

input_items vector of pointers to the input items, one entry per input
stream
output_items vector of pointers to the output items, one entry per
output stream

Am I correct in understanding that the input_items CAN point to a
vector type of inputs? I plan to implement two input channels
of vector type. Therefore I plan to pass TWO POINTERS of
vector type as “input_items” to general_work.

Note that the discussion on this website:
http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html
only used one
“channel” of inputs since it only took values from a single stream. I
plan to take TWO CHANNELS of inputs wherein each channel contains
10000 inputs.

Thanks!

On Mon, Jan 07, 2008 at 10:28:39AM +0800, Jonas Gacrama wrote:

These are some of the input parameters of gr_block::general_work() :

input_items vector of pointers to the input items, one entry per input stream
output_items vector of pointers to the output items, one entry per
output stream

Am I correct in understanding that the input_items CAN point to a
vector type of inputs?

No, the data items must be “plain-old-data”…
Something that can be copied safely with memcpy.

I plan to implement two input channels
of vector type. Therefore I plan to pass TWO POINTERS of
vector type as “input_items” to general_work.

Do you mean that each “item” is conceptually a vector of 10,000
floats? And that your block operates on two input streams, each of
which contains “items” that are vectors of 10,000 floats?

If so, you input signature should be:

gr_make_io_signature(2, 2, 10000 * sizeof(float))

Unless your block has a time varying i/o rate between input and
output, I’d recommend that you derive your class from gr_sync_block
instead of gr_block. It’s easier that way.

Note that the discussion on this website:
http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html
only used one
“channel” of inputs since it only took values from a single stream. I
plan to take TWO CHANNELS of inputs wherein each channel contains
10000 inputs.

One of the joys of Free Software is that the code is available to
inspect. There are 100’s of blocks to look at, and at least 1/2 of
them take more than a single input.

In particular, you may want to look at the code for
gr_add_vff.{h,cc} which adds streams of vectors of floats together and
gr_add_ff.{h,cc} which adds streams of floats together.

Eric

Yes, each “item” is supposed to be a vector of 10000 floats; and yes,
each input stream contains 10000 floats. I chose a vector type for
flexibility but I could always go back to turning it into a “plain old
data”.

In that case, could I pass a multidimensional array as an input
argument to general_work? For example, I pass array_name[2][10000]
where the main index [2] in this case, represents 2 inputs streams?

I don’t really intend to vary the input and output rates, but thanks
for the suggestion on using gr_sync_block! I’ll try it too.

As a side note to , I already created functions that do just
that. It’s already incorporated into the main signal processing block
that I am creating. But thanks for the suggestion! I’ll see if I could
use it.

=)