X Y to Azimuth & Distance Convesion

Max Gausepohl's icon

Hello Community,

I am currently working on a project that involves some old fashioned gaming joysticks as audio controllers. Right now, I am trying to integrate the SPAT tools developed at IRCAM to be able to work with some more advanced spatialisation techniques. But I am a bit stuck with writing a patch that is able to translate X Y values generated by the joysticks to a azimuth and distance values I can then feed into the SPAT panning tools.

I managed to get the Azimuth values, but I cannot figure out how to get the distance values and another problem is that I cannot get the mapping muttons (to map to SPAT panning) to work properly, they behave very strangely and I don't really know why, because I don't fully understand the magic behind this little bpatcher I'm always taking from the LFO tool.

I have looked into poltocar, but there I cannot get the distance value. Point of reference for the distance should be the center.

Maybe someone here knows how to achieve this?

I will attach my current patch here:

XYtoAzimuthDistance.amxd
amxd 315.54 KB

TFL's icon

Most spat objects accept carthesian coordinates with /xy messages, no need to handle the azimuth/distance conversion yourself. See spat5.positions.maxhelp for notation examples.

But if you still want to do this yourself, you need [cartopol] (carthesian to polar), not [poltocar]:

Max Patch
Copy patch and select New From Clipboard in Max.

Max Gausepohl's icon

Thank you! It works now, perfect!

The mapping is still behaving strangely, but that's somthing to figure out another time