Can not interpolate from two delay blocks

Algorithm development and general DSP issues

Moderator: frank

Post Reply
igorrr
Posts: 3
Joined: Wed May 18, 2016 9:27 am

Can not interpolate from two delay blocks

Post by igorrr »

Hello,

I try to do interpolated delay reads from two delay blocks. But reading from the second block is not one sample delayed as it should be, thus interpolation can not be done for that block.
Here is the test code:
mem left 5000
mem right 5000

equ time reg1

sof 0,0.01
wrax time, 0 ; Save it

rdax adcl,0.5
wra left,0

rdax adcr,0.5
wra right,0

;get second value:
or left * 256
or %00000000_00000001_00000000 ;add 1 to address
rdax time, 1.0 ;get pointer back and add
wrax addr_ptr,0 ;load pointer again
rmpa 1
wrax dacl,0


;get second value:
or right * 256
or %00000000_00000001_00000000 ;add 1 to address
rdax time, 1.0 ;get pointer back and add
wrax addr_ptr,0 ;load pointer again
rmpa 1
wrax dacr,0
Left channels is properly 1 sample delayed, but right channels is not, the line
“or %00000000_00000001_00000000”
does nothing for this channel.

If memory declaration will be in other order
mem right 5000
mem left 5000

instead of
mem left 5000
mem right 5000
that one sample error will be in another channel.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Can not interpolate from two delay blocks

Post by frank »

Doing an "or" will not add 1 to the address it will simply set the LSB to 1. Here is what is happening:

"left" is 5001 long, remember that memory is allocated as N+1 to allow both read and write pointers so its address ranges from 0 to 5000. ORing in the 1 sets the base address to 1 since it is currently 0

"right" runs from 5001 to 10001 but the LSB is already set so ORing in a 1 does nothing.

You need to actually add in a 1 not or in a 1 to increment the address
Frank Thomson
Experimental Noize
igorrr
Posts: 3
Joined: Wed May 18, 2016 9:27 am

Re: Can not interpolate from two delay blocks

Post by igorrr »

Many thanks Frank!
What is the best way to increment the address by 1 sample?
I added this line
“sof 1.0001,0”
making it
or right*256
rdax time, 1.0
sof 1.0001,0
wrax addr_ptr,0
which works, but looks like there is a better way to do it.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Can not interpolate from two delay blocks

Post by frank »

The best solution depends on the program, what you are trying to do ,etc. The RDAX way is really good as it allows you to add directly from a register, pre-calculate the offset and save it for later use, etc. So it depends on what you are doing and if you need exact offsets or if "close enough" is ok.
Frank Thomson
Experimental Noize
Post Reply