Work out the rate of change or similar (accelerometer data)??

ilikebycles's icon

Hi,
Im trying to use a 3-axis acclerometer to capture gestural movements from a performer and use that data elsewhere in my patch. At the moment I have it just triggering an event if the movement goes above a certain threshold for example however it does not feel particularly responsive that way.

I've investigated using the change~ and edge~ objects then capture that peak to try and improve matters however to no avail....
Is there a better way of doing this or to calculate the rate of change of the data in order to make it some function of how fast it is moved?

Any suggestions at all would be greatly appreciated! Thanks.
===========================================================================
{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "Z-AXIS",
                "fontsize" : 12.0,
                "numoutlets" : 0,
                "patching_rect" : [ 1085.0, 106.0, 55.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-34",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "numoutlets" : 1,
                "patching_rect" : [ 1331.0, 558.0, 20.0, 20.0 ],
                "outlettype" : [ "bang" ],
                "id" : "obj-49",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "isn't the same",
                "fontsize" : 11.595187,
                "numoutlets" : 0,
                "patching_rect" : [ 1312.0, 580.0, 86.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-50",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "numoutlets" : 1,
                "patching_rect" : [ 1268.0, 558.0, 20.0, 20.0 ],
                "outlettype" : [ "bang" ],
                "id" : "obj-51",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "edge~",
                "fontsize" : 11.595187,
                "numoutlets" : 2,
                "patching_rect" : [ 1268.0, 535.0, 82.0, 20.0 ],
                "outlettype" : [ "bang", "bang" ],
                "fontname" : "Arial",
                "id" : "obj-52",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "==~ 0.",
                "fontsize" : 11.595187,
                "numoutlets" : 1,
                "patching_rect" : [ 1268.0, 510.0, 44.0, 20.0 ],
                "outlettype" : [ "signal" ],
                "fontname" : "Arial",
                "id" : "obj-53",
                "numinlets" : 2
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "increasing",
                "fontsize" : 11.595187,
                "numoutlets" : 0,
                "patching_rect" : [ 1183.0, 580.0, 74.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-21",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "number~",
                "fontsize" : 11.595187,
                "numoutlets" : 2,
                "patching_rect" : [ 1072.0, 513.0, 56.0, 20.0 ],
                "sig" : 0.0,
                "outlettype" : [ "signal", "float" ],
                "mode" : 2,
                "fontname" : "Arial",
                "id" : "obj-22",
                "numinlets" : 2
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "numoutlets" : 1,
                "patching_rect" : [ 1189.0, 558.0, 20.0, 20.0 ],
                "outlettype" : [ "bang" ],
                "id" : "obj-23",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "edge~",
                "fontsize" : 11.595187,
                "numoutlets" : 2,
                "patching_rect" : [ 1189.0, 537.0, 43.0, 20.0 ],
                "outlettype" : [ "bang", "bang" ],
                "fontname" : "Arial",
                "id" : "obj-54",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "button",
                "numoutlets" : 1,
                "patching_rect" : [ 1131.0, 558.0, 20.0, 20.0 ],
                "outlettype" : [ "bang" ],
                "id" : "obj-56",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "edge~",
                "fontsize" : 11.595187,
                "numoutlets" : 2,
                "patching_rect" : [ 1131.0, 537.0, 43.0, 20.0 ],
                "outlettype" : [ "bang", "bang" ],
                "fontname" : "Arial",
                "id" : "obj-57",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "==~ 1.",
                "fontsize" : 11.595187,
                "numoutlets" : 1,
                "patching_rect" : [ 1189.0, 511.0, 44.0, 20.0 ],
                "outlettype" : [ "signal" ],
                "fontname" : "Arial",
                "id" : "obj-61",
                "numinlets" : 2
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "==~ -1.",
                "fontsize" : 11.595187,
                "numoutlets" : 1,
                "patching_rect" : [ 1131.0, 511.0, 48.0, 20.0 ],
                "outlettype" : [ "signal" ],
                "fontname" : "Arial",
                "id" : "obj-62",
                "numinlets" : 2
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "line~",
                "fontsize" : 11.595187,
                "numoutlets" : 2,
                "patching_rect" : [ 1131.0, 440.0, 35.0, 20.0 ],
                "outlettype" : [ "signal", "bang" ],
                "fontname" : "Arial",
                "id" : "obj-64",
                "numinlets" : 2
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "change~",
                "fontsize" : 11.595187,
                "numoutlets" : 1,
                "patching_rect" : [ 1131.0, 468.0, 55.0, 20.0 ],
                "outlettype" : [ "signal" ],
                "fontname" : "Arial",
                "id" : "obj-65",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "decreasing",
                "fontsize" : 11.595187,
                "numoutlets" : 0,
                "patching_rect" : [ 1102.0, 580.0, 74.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-66",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "the same",
                "fontsize" : 11.595187,
                "numoutlets" : 0,
                "patching_rect" : [ 1253.0, 580.0, 69.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-32",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "number",
                "fontsize" : 12.0,
                "numoutlets" : 2,
                "patching_rect" : [ 1131.0, 408.0, 50.0, 20.0 ],
                "outlettype" : [ "int", "bang" ],
                "fontname" : "Arial",
                "id" : "obj-46",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "0G",
                "fontsize" : 12.0,
                "numoutlets" : 0,
                "patching_rect" : [ 1182.0, 227.0, 29.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-5",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "1G",
                "fontsize" : 12.0,
                "numoutlets" : 0,
                "patching_rect" : [ 1180.0, 154.0, 29.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-4",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "comment",
                "text" : "-1G",
                "fontsize" : 12.0,
                "numoutlets" : 0,
                "patching_rect" : [ 1182.0, 310.0, 29.0, 20.0 ],
                "fontname" : "Arial",
                "id" : "obj-3",
                "numinlets" : 1
            }

        }
,         {
            "box" :             {
                "maxclass" : "slider",
                "numoutlets" : 1,
                "patching_rect" : [ 1136.0, 93.0, 42.0, 295.0 ],
                "outlettype" : [ "" ],
                "bgcolor" : [ 1.0, 0.984314, 0.941176, 1.0 ],
                "knobcolor" : [ 0.0, 0.776471, 0.388235, 1.0 ],
                "bordercolor" : [ 0.0, 0.0, 0.0, 1.0 ],
                "id" : "obj-72",
                "numinlets" : 1
            }

        }
],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-72", 0 ],
                "destination" : [ "obj-46", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-64", 0 ],
                "destination" : [ "obj-65", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-65", 0 ],
                "destination" : [ "obj-22", 0 ],
                "hidden" : 0,
                "midpoints" : [ 1140.5, 498.0, 1081.5, 498.0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-65", 0 ],
                "destination" : [ "obj-62", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-62", 0 ],
                "destination" : [ "obj-57", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-57", 0 ],
                "destination" : [ "obj-56", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-65", 0 ],
                "destination" : [ "obj-61", 0 ],
                "hidden" : 0,
                "midpoints" : [ 1140.5, 498.0, 1198.5, 498.0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-61", 0 ],
                "destination" : [ "obj-54", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-54", 0 ],
                "destination" : [ "obj-23", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-65", 0 ],
                "destination" : [ "obj-53", 0 ],
                "hidden" : 0,
                "midpoints" : [ 1140.5, 498.0, 1277.5, 498.0 ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-53", 0 ],
                "destination" : [ "obj-52", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-52", 0 ],
                "destination" : [ "obj-51", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-52", 1 ],
                "destination" : [ "obj-49", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-46", 0 ],
                "destination" : [ "obj-64", 0 ],
                "hidden" : 0,
                "midpoints" : [ ]
            }

        }
]
}

brendan mccloskey's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi
it's quite easy to detect and output value peaks, which would give you a kind of velocity capture functionality, but it's a little unclear from your post exactly what you require; here's a solution using just Max objects ([togedge], [gate] and [delay], and assuming that your values always return to zero before the next peak, but i don't think this is what you want:

ilikebycles's icon

Thanks alot, I guess what I'm really trying to do is to find a way to tell not just the peak value of the accelerometer data (which is just scaled 0-127) but how fast the accelerometer was moved to arrive there -some kind of differential possibly?

Or I believe I could arrive at much the same effect by simply capturing the peak value of where the data stops increasing and begins to decrease, allthough I have been unsuccessgul in doing this!!

Hope this is a little clearer!?

Thanks again.

Beep's icon

subtract the peak from the trough after a short sampling window? For example sample min and max every 10ms and the larger the differential the faster the accelerometer has moved?

Beep's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a little patch I knocked up that that should tell you how fast the accelerometer moved

Tim Lloyd's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here is an alternative which does a similar thing to brokenman's patch:

ilikebycles's icon

Thanks alot guys! Thats exactly what I was I was going for. Good to know the Max forum has people keen to help.