First, I need to register a stream of data in an array. For example, data from the X-axis of a rigid body (in OptiTrack, motion capture system) for 10 seconds.
Then it is necessary to save the data of this array in a text file so that this data can be read out each time the patch is started and rearranged in the array. In this way the specific movement, or better our reference movement, is saved and automatically loaded into the patch every time.
The next step is to create a RingBuffer, a buffer that continuously records the product data. This must be at least as large as the data set that we want to recognize.
The RingBuffer Slider can look into the past so that it can correlate everything with the reference signal.
For example, I set the data resampling to a rate of 8.333 milliseconds, since the data I’m usicing are coming from OptiTrack, and they reach a maximum of 120 fps. This means 1000/120 = 8.333.
This is the interval between one sample and another.
Another index reads both arrays at the same time, which are first multiplied and then their results are added.
The final result indicates the degree of correlation, the higher this number, the higher the correlation.
In this way, we can set a threshold to establish the minimum acceptable level of correlation, so that we can decide how similar the 2 data streams have to be to generate an output.
One problem that could arise is the continuous output trigger when this value is set too low.
This can be solved, however, by setting a delay that defines the time after which this trigger can be shifted, or by triggering a number immediately after starting the loops in order to set the threshold value to a very high value, which with Cross-correlation is unattainable.
It should be noted, however, that comparing more data streams to have a more precise correlation (for example X, Y and Z axes) can cause computational problems for the computer as a large data flow is continuously examined and compared.