On Thu, Mar 24, 2011 at 6:29 AM, Patrik Eliardsson
<address@hidden>
wrote:
Hi,
I've tried the new stream tags and like them,
but when I've a block in my flowgraph that change the stream rate I'm not
sure how the absolute sample number is calculated.
Consider the
flowgraph below where B0, B1 and B4 are gr_sync_block and B2 is a gr_block
that increases the stream rate in the flowgraph.
B0 -> B1 -> B2
-> B4
If I set tags on sample 0 and 200 in block B0 and check the
tags in block B1 everything is correct, I find them at sample 0 and 200. But
if I check the tags in block B4 I find them at 0 and 400 while I expected to
find them on 0 at 527. The B2 block consumes 200 samples and produces 527
samples, this is a rate of 2.635 and the tag absolute sample number is
increased by a ratio of 2. How is the absolute sample number
calculated?
Patrik, glad you've gotten into using the stream tags. To answer your
question, the sample numbers are changed based on the relative rate you set
for your block. When you use a gr_sync_decimator with a decimation rate of D,
the relative_rate of that block is set in the constructor to be 1.0/(float)D.
Likewise, when using a gr_sync_interpolator, the relative rate is set to
(float)I.
When a stream tag is passed between blocks, the schedule looks at the
relative rate, and if it is not 1.0, it will adjust the value by multiplying
by relative_rate.
It strikes me that possible block B2 is having its relative_rate set
incorrectly. It could be a casting problem that has truncated the math to 2
instead of 2.635. You can ask a block it's rate with relative_rate() to see
what it thinks its rate is.