xyinInstrument Control:Sensing and Controlxyinxyin
Sense the cursor position in an output window
Description
Sense the cursor position in an output window. When xyin is called the position of the mouse within the output window is used to reply to the request. This simple mechanism does mean that only one xyin can be used accurately at once. The position of the mouse is reported in the output window.
Syntaxkx, ky xyin iprd, ixmin, ixmax, iymin, iymax [, ixinit] [, iyinit]Initializationiprd -- period of cursor sensing (in seconds). Typically .1 seconds.
xmin, xmax, ymin, ymax -- edge values for the x-y coordinates of a cursor in the input window.
ixinit, iyinit (optional) -- initial x-y coordinates reported; the default values are 0,0. If these values are not within the given min-max range, they will be coerced into that range.
Performancexyin samples the cursor x-y position in an input window every iprd seconds. Output values are repeated (not interpolated) at the k-rate, and remain fixed until a new change is registered in the window. There may be any number of input windows. This unit is useful for real-time control, but continuous motion should be avoided if iprd is unusually small.
Depending on your platform and distribution, you might need to enable displays using the --displays command line flag.
Examples
Here is an example of the xyin opcode. It uses the file xyin.csd.
Example of the xyin opcode.See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
As the values of kx and ky change, they will be printed out like this:
kx=8.612036, ky=22.677933
kx=10.765685, ky=15.644135
See alsoSensing and Control: Keyboard and mouse sensingCreditsExample written by &namekevin;.