Forums > Dev

Accessing previous input samples

Mar 18 2011 | 9:02 pm

I’m trying to implement the following difference equation (an antiresonator) as a max external

y(n) = (1/A)*x(n) – (B/A)*x(n-2) – (C/A)*x(n-3)

My question is how do I access the previous samples required for this. I have done this many times in non real-time situations (in Matlab) but I’m a little unsure of how to deal with the input vector.
Is it a matter of simply subtracting 1 from the *in pointer for each previous sample or is it necessary to store the values somewhere?

Mar 19 2011 | 10:57 am

Thanks for the reply.
I’ll try that out!

Mar 21 2011 | 7:03 pm

That worked out fine.
I made an array of 4 elements to store the values of x(n)…..x(n-3) and shifted them to the right at the beginning of each iteration of the dsp loop. Quite simple in the end. I’m just not so used to processing streams like that.
Thanks for the help.

Mar 22 2011 | 11:23 am

You should probably look up "ring buffer" in a text book on data structures. It is more efficient than shifting data around at every sample. However, if your buffer is only four elements it won’t make a big difference.

Still, for future reference. If you try to scale your approach to delay lines of several milliseconds (ie hundreds or thousands of samples) it will be imperative to use a more efficient approach.

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > Dev