Forums > MaxMSP

Object to use to store and analyse a realtime stream of numbers?

May 09 2011 | 11:04 pm

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?

Hope that all makes sense!

May 10 2011 | 1:16 am

[zl stream] might be worth a look!

May 10 2011 | 9:56 am

Luke, you’re a saint! This seems to be exactly what I’ve been looking for.

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

Forums > MaxMSP