# X-Y input analysis of change in direction (tablet)

Hey everyone,
Hope the holidays are looking bright for all! I have a set of problems to solve involving complex input analysis being converted to usable interactive parameters. This sort of thing is very much in the forefront these days, so I’m hoping that someone has used Touch in this capacity and has some pointers, or at least to start some discussion on techniques and approaches.

Basically, I have taken one of the Painter components posted by Jarret and stripped it way down until it is simply a 2D stroke maker. Currently, I am working with my musician partner to do some fun synasthetic blending of controls, in which I create tones with my strokes, and affect those tones with pressure, tilt, etc, while he plays his guitar and effects the ‘bleeding’ feedback of the strokes with audio input (coming in via OSC from another computer right now).

The final piece of the puzzle to make this little thing really ‘sing’ is to use the data from my strokes as they are being generated to derive my ‘change in direction’ as I am drawing. I am looking to generate one or two parameters that I can send over to Ableton to affect a tone as I am drawing. I see this is as either being a change in relative direction based on the history of the stroke with a variable amount of previous points, or a global change in angle or direction based on a stationary ‘up’ direction. Ideally, I would like to work towards the former, though the latter sounds easier.

I have been wracking my not-so-mathematically-capable brain about how to do this, and how to do it in the Touch environment. I can see working in Processing or Open Frameworks how I might accumulate the coordinates of the stroke, convert them to vectors, get the angles between them, and then run some kind of averaging over the set to determine how it has changed relative to the previous input points.

I have tried doing something like this in touch, with a Trail CHOP, an Expression involving Vectorizing the points and grabbing the angle between, an analysis CHOP and a few filters to smooth things out. This is what I am attaching to this post (the angle analysis OPs are to the left of the painter COMP inside the main component) The data I am getting seems pretty choppy, and also won’t give any sort of negative value for the angle differences, which could be useful in converting this into a parameter to affect sound.

``````I am probably missing something, or possibly many things here...
``````

Another approach I have been thinking of is to weigh incoming angle differences against the previous (either in a Trail or actually from the Stroke tables in the stroke COMPs) and using this to either add to or subtract from the parameter that would be sent to Ableton ( I am doing conversion to MIDI in PD right now, so I don’t need to worry about that here). This is a sort of dialing up or dialing down of a global change in direction approach.

Anyways, I realize this is a pretty open ended and complex subject, so I’m just wondering if anyone has some starting points, or worked with something like this before. It almost seems like something akin to CV type stuff, or multi-touch gestural recognition. My other dilemma, as I am still getting used to workflow in touch, is how to implement more code like solutions into the data flow. Is stringing together expression and function CHOPs an efficient way to do things?, or do people write more complex scripts for iterating over past values and inserting that into the data stream?

Hope I haven’t scared too many of you away with the long post! Thanks!

Cheers,
Peter
archo-painter_angle_edit.tox (279 KB)

I think what might help you out is the Slope CHOP. If you feed the Slope CHOP with your x and y channels, it will give you the change in position (direction). This will give you negative values as well(left in x, down in y), maybe its a good starting point?

Ha ha! You guys are great!
Thank you ben, the Slope CHOP is most certainly what I needed.
I used it to calculate the changes in x and y, and then used an atan() function to turn that data into change in angle in the x and y ( ala tan(theta) = y/x ). With a filter on it it provides pretty much exactly the kind of data I’m looking for.

I may delve further to try and create a way generate relative direction data based on the general direction of the stroke, but for now this works like a charm. Thanks

I’m attaching the .tox
painter_direction_osc.tox (276 KB)