FLxyin
Prev | Orchestra Opcodes and Operators | Next

## FLxyin

FLxyin — Senses the mouse cursor position in a user-defined area inside an FLpanel.

## Description

Similar to xyin, sense the mouse cursor position in a user-defined area inside an FLpanel.

## Syntax

    koutx, kouty, kinside  FLxyin ioutx_min, ioutx_max, iouty_min, iouty_max, \
          iwindx_min, iwindx_max, iwindy_min, iwindy_max [, iexpx, iexpy, ioutx, iouty]

## Initialization

ioutx_min, ioutx_max - the minimum and maximum limits of the interval to be output (X or horizontal axis).

iouty_min, iouty_max - the minimum and maximum limits of the interval to be output (Y or vertical axis).

iwindx_min, iwindx_max - the X coordinate of the horizontal edges of the sensible area, relative to the FLpanel ,in pixels.

iwindy_min, iwindy_max - the Y coordinates of the vertical edges of the sensible area, relative to the FLpanel, in pixels.

iexpx, iexpy - (optional) integer numbers denoting the behavior of the x or y output: 0 -> output is linear; -1 -> output is exponential; any other number indicates the number of an existing table that is used for indexing. With a positive value for table number, linear interpolation is provided in table indexing. A negative table number suppresses interpolation. Notice that in normal operations, the table should be normalized and unipolar (i.e. all table elements should be in the zero to one range). In this case all table elements will be rescaled according to imax and imin. Anyway, it is possible to use non-normalized tables (created with a negative table number, that can contain elements of any value), in order to access the actual values of table elements, without rescaling, by assigning 0 to iout_min and 1 to iout_max.

ioutx, iouty – (optional) initial output values.

## Performance

koutx, kouty - output values, scaled according to user choices.

kinside - a flag that informs if the mouse cursor falls out of the rectangle of the user-defined area. If it is out of the area, kinside is set to zero.

FLxyin senses the mouse cursor position in a user-defined area inside an FLpanel. When FLxyin is called, the position of the mouse within the chosen area is returned at k-rate. It is possible to define the sensible area, as well the minimum and maximum values corresponding to the minimum and maximum mouse positions. Mouse buttons don’t need to be pressed to make FLxyin to operate. It is able to function correctly even if other widgets (present in the FLpanel) overlap the sensible area.

FLxyin unlike most other FLTK opcodes can't be used inside the header, since it is not a widget. It is just a definition of an area for mouse sensing within an FLTK panel.

## Examples

Here is an example of the FLxyin opcode. It uses the file FLxyin.csd.

Example 320. Example of the FLxyin opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    </CsOptions>
    <CsInstruments>

    sr=48000
    ksmps=128
    nchnls=2

    ; Example by Andres Cabrera 2007

    FLpanel	"FLxyin", 200, 100, -1, -1, 3
    FLpanelEnd
    FLrun

    instr 1
      koutx, kouty, kinside FLxyin 0, 10, 100, 1000, 10, 190, 10, 90
      aout buzz 10000, kouty, koutx, 1
      printk2 koutx
      outs aout, aout
    endin

    </CsInstruments>

    <CsScore>
    f 1 0 1024 10 1
    i 1 0 3600

    e

    </CsScore>
    </CsoundSynthesizer>

Here is another example of the FLxyin opcode. It uses the file FLxyin-2.csd.

Example 321. Example of the FLxyin opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in    No messages
    -odac           -iadc     -d     ;;;RT audio I/O
    </CsOptions>
    <CsInstruments>

    sr=44100
    kr=441
    ksmps=100
    nchnls=2

    ; Example by Gabriel Maldonado

    	FLpanel	"Move the mouse inside this panel to hear the effect",400,400
    	FLpanel_end
    	FLrun

    	instr 1

    k1, k2, kinside	FLxyin   50, 1000, 50, 1000, 100, 300, 50, 250, -2,-3
    ;if k1 <= 50 || k1 >=5000 || k2 <=100 || k2 >= 8000 kgoto end ; if cursor is outside bounds, then don't play!!!

    a1	oscili	3000, k1, 1
    a2	oscili	3000, k2, 1

    	outs	a1,a2
    printk2 k1
    printk2 k2, 10
    printk2 kinside, 20
    end:
    	endin

    </CsInstruments>
    <CsScore>

    f1 0 1024 10 1
    f2 0 17 19 1 1 90 1
    f3 0 17 19 2 1 90 1
    i1 0 3600

    </CsScore>
    </CsoundSynthesizer>

## See Also

FLpanel

## Credits

Author: Gabriel Maldonado

New in version 5.06

Prev | Up | Next
FLvslidBnk2 | Home | fmanal