FLknob
Prev | Orchestra Opcodes and Operators | Next

## FLknob

FLknob — A FLTK widget opcode that creates a knob.

## Description

A FLTK widget opcode that creates a knob.

## Syntax

    kout, ihandle FLknob "label", imin, imax, iexp, itype, idisp, iwidth, \
          ix, iy [, icursorsize]

## Initialization

ihandle -- a handle value (an integer number) that unequivocally references a corresponding widget. This is used by other opcodes that modify a widget's properties (see Modifying FLTK Widget Appearance). It is automatically utput by FLknob and must not be set by the user label. (The user label is a double-quoted string containing some user-provided text placed near the widget.)

“label” -- a double-quoted string containing some user-provided text, placed near the corresponding widget.

imin -- minimum value of output range.

imax -- maximum value of output range.

iexp -- an integer number denoting the behaviour of valuator:

- 0 = valuator output is linear

- -1 = valuator output is exponential

All other positive numbers for iexp indicate the number of an existing table that is used for indexing. Linear interpolation is provided in table indexing. A negative table number suppresses interpolation.

| IMPORTANT!
Notice that the tables used by valuators must be created with the ftgen opcode and placed in the orchestra before the corresponding valuator. They can not placed in the score. In fact, tables placed in the score are created later than the initialization of the opcodes placed in the header section of the orchestra.

itype -- an integer number denoting the appearance of the valuator.

The itype argument can be set to the following values:

- 1 - a 3-D knob

- 2 - a pie-like knob

- 3 - a clock-like knob

- 4 - a flat knob

A 3-D knob.

A pie knob.

A clock knob.

A flat knob.

idisp -- a handle value that was output from a previous instance of the FLvalue opcode to display the current value of the current valuator in the FLvalue widget itself. If the user does not want to use this feature that displays current values, it must be set to a negative number by the user.

iwidth -- width of widget.

iheight -- height of widget.

ix -- horizontal position of upper left corner of the valuator, relative to the upper left corner of corresponding window (expressed in pixels).

iy -- vertical position of upper left corner of the valuator, relative to the upper left corner of corresponding window (expressed in pixels).

icursorsize (optional) -- If FLknob's itype is set to 1 (3D knob), this parameter controls the size of knob cursor.

## Performance

kout -- output value

FLknob puts a knob in the corresponding container.

## Examples

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

Example 313. Example of the FLknob 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    No messages
    -odac           -iadc     -d     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o FLknob.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; A sine with oscillator with flknob controlled frequency
    sr = 44100
    kr = 441
    ksmps = 100
    nchnls = 1

    FLpanel "Frequency Knob", 900, 400, 50, 50
        ; Minimum value output by the knob
        imin = 200
        ; Maximum value output by the knob
        imax = 5000
        ; Logarithmic type knob selected
        iexp = -1
        ; Knob graphic type (1=3D knob)
        itype = 1
        ; Display handle (-1=not used)
        idisp = -1
        ; Width of the knob in pixels
        iwidth = 70
        ; Distance of the left edge of the knob
        ; from the left edge of the panel
        ix = 70
        ; Distance of the top edge of the knob
        ; from the top of the panel
        iy = 125

        gkfreq, ihandle FLknob "Frequency", imin, imax, iexp, itype, idisp, iwidth, ix, iy
    ; End of panel contents
    FLpanelEnd
    ; Run the widget thread!
    FLrun

    ; Set the widget's initial value
    FLsetVal_i 300, ihandle

    instr 1
        iamp = 15000
        ifn = 1
        asig oscili iamp, gkfreq, ifn
        out asig
    endin

    </CsInstruments>
    <CsScore>

    ; Function table that defines a single cycle
    ; of a sine wave.
    f 1 0 1024 10 1

    ; Instrument 1 will play a note for 1 hour.
    i 1 0 3600
    e

    </CsScore>
    </CsoundSynthesizer>

Here is another example of the FLknob opcode, showing the different styles of knobs and the usage of FLvalue to display a knob's value. It uses the file FLknob-2.csd.

Example 314. More complex example of the FLknob opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in    No messages
    -odac           -iadc     -d     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o FLknob.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    ;By Andres Cabrera 2007
    FLpanel "Knob Types", 330, 230, 50, 50
        ; Distance of the left edge of the knob
        ; from the left edge of the panel
        ix = 20
        ; Distance of the top edge of the knob
        ; from the top of the panel
        iy = 20

        ;Create boxes that display a widget's value
        ihandleA FLvalue "A", 60, 20, ix + 130, iy + 110
        ihandleB FLvalue "B", 60, 20, ix + 220, iy + 110
        ihandleC FLvalue "C", 60, 20, ix + 130, iy + 160
        ihandleD FLvalue "D", 60, 20, ix + 220, iy + 160

        ; The foru types of FLknobs
        gkdummy1, ihandle1 FLknob "Type 1", 200, 5000, -1, 1, ihandleA, 70, ix, iy, 90
        gkdummy2, ihandle2 FLknob "Type 2", 200, 5000, -1, 2, ihandleB, 70, ix + 100, iy
        gkdummy3, ihandle3 FLknob "Type 3", 200, 5000, -1, 3, ihandleC, 70, ix + 200, iy
        gkdummy4, ihandle4 FLknob "Type 4", 200, 5000, -1, 4, ihandleD, 70, ix , iy + 100
    ; End of panel contents
    FLpanelEnd
    ; Run the widget thread!
    FLrun

    ; Set the color of widgets
    FLsetColor 20, 23, 100, ihandle1
    FLsetColor 0, 123, 100, ihandle2
    FLsetColor 180, 23, 12, ihandle3
    FLsetColor 10, 230, 0, ihandle4

    FLsetColor2 200, 230, 0, ihandle1
    FLsetColor2 200,0 ,123 , ihandle2
    FLsetColor2 180, 180, 100, ihandle3
    FLsetColor2 180, 23, 12, ihandle4

    ; Set the initial value of the widget
    FLsetVal_i 300, ihandle1
    FLsetVal_i 1000, ihandle2

    instr 1
    ; Nothing here for now
    endin

    </CsInstruments>
    <CsScore>

    f 0 3600   ;Dumy table to make csound wait for realtime events

    e

    </CsScore>
    </CsoundSynthesizer>

## See Also

FLcount, FLjoy, FLroller, FLslider, FLtext

## Credits

Author: Gabriel Maldonado

New in version 4.22

Example written by Iain McCurdy, edited by Kevin Conder.

Prev | Up | Next
FLkeyIn | Home | FLlabel