# Bug in block::declare\_sample\_delay

**URL:** <https://www.ruby-forum.com/t/bug-in-block-declare-sample-delay/243095>\
**Category:** GNU Radio\
**Created:** [August 21, 2015, 12:48am UTC](https://www.ruby-forum.com/t/bug-in-block-declare-sample-delay/243095 "2015-08-21T00:48:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 21, 2015, 12:48am UTC](https://www.ruby-forum.com/t/bug-in-block-declare-sample-delay/243095/1 "2015-08-21T00:48:29Z")

</div>

Hello,  
I think that the declare\_sample\_delay (and/or the way it is used) is  
implemented incorrectly for interpolator blocks. Using GR 3.7.6.

The delay should be added **after** scaling the offset by the  
interpolation ratio, not before. For example, using the  
filter.interp\_fir\_filter(4,[1,2,3,4]):  
If a tag is on sample2, and the sample\_delay is declared as one, the  
output tag should be on sample 2\*4+1=9. However, it falls on sample 12  
= (2+1)\*4.

Here’s an example to demonstrate the error:

from gnuradio import gr, blocks, filter  
import pmt

top = gr.top\_block()  
tag = gr.tag\_utils.python\_to\_tag((2,  
pmt.to\_pmt(‘A’),  
pmt.PMT\_NIL,  
pmt.PMT\_NIL))

src = blocks.vector\_source\_f(range(0, 50, 10), tags=[tag])  
dut = filter.interp\_fir\_filter\_fff(4, [1, 2, 3, 4])  
dut.declare\_sample\_delay(1)  
snk = blocks.vector\_sink\_f()

top.connect(src, dut, snk)  
top.run()

result = snk.data()  
tags = snk.tags()  
print tags[0].offset

Regards.
