I’m currently modifying a patch thats receives realtime XYZ data from an accelerometer, and then displays the data in three separate [function] objects as realtime ‘x,y’ lines.
I’m then trying to go about analysing the three separate streams of integers so that I can calculate the difference between each consecutive number that the accelerometer sends. For example, putting it in layman terms, if I swiftly move the accelerometer up and down it could send out a stream of numbers such as 65, 70, 75, 80, 75, 70, 65, 60, 65 etc…, and it is the value that each number ascends or descends by that I want to output (in the case of my example, clearly it would be 5, 5, 5, -5, -5, -5, 5).
I am currently getting the difference values by dumping-out a realtime list of the x,y points of the [function] objects, and then I’ve built a simple algorithm that compares the most recently accelerometer integer value to the last value, and outputs the difference.
It’s working well but there’s a bit of a noticeable delay through the process of receiving the accelerometer data and outputting the difference values, which I’m guessing is due to the way i’ve gone around designing the patch.
My question is; is there a better object than [function] to use to store and output a stream of realtime integers? I don’t need to display the data graphical; just a simple array or buffer than only the stores the last amount of n values is all I need, but I’m finding it hard to find the correct object. Also, is there an object that calculates the difference between two values?