FLbutBank

FLbutBank — A FLTK widget opcode that creates a bank of buttons.

Description

Plugin opcode in widgets. This opcode is part of the plugin repository and has to be installed separately. These FLTK widgets do not work on the Mac. The plugin repository can be found here: https://github.com/csound/plugins

A FLTK widget opcode that creates a bank of buttons.

Syntax

kout, ihandle FLbutBank itype, inumx, inumy, iwidth, iheight, ix, iy, \
      iopcode [, kp1] [, kp2] [, kp3] [, kp4] [, kp5] [....] [, kpN]

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 output by FLbutBank 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.)

itype -- an integer number denoting the appearance of the widget. The valid numbers are:

  • 1 - normal button

  • 2 - light button

  • 3 - check button

  • 4 - round button

You can add 20 to the value to create a "plastic" type button. (Note that there is no Platic Round button. i.e. if you set type to 24 it will look exactly like type 23).

inumx -- number of buttons in each row of the bank.

inumy -- number of buttons in each column of the bank

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

iopcode -- score opcode type. You have to provide the ascii code of the letter corresponding to the score opcode. At present time only i (ascii code 105) score statements are supported. A zero value refers to a default value of i. So both 0 and 105 activates the i opcode. A value of -1 disables this opcode feature.

Performance

kout -- output value

kp1, kp2, ..., kpN -- arguments of the activated instruments.

The FLbutBank opcode creates a bank of buttons. For example, the following line:

gkButton,ihb1  FLbutBank  22, 8, 8, 380, 180, 50, 350, 0, 7, 0, 0, 5000, 6000
        

will create the this bank:

FLbutBank.

FLbutBank.

A click to a button checks that button. It may also uncheck a previous checked button belonging to the same bank. So the behaviour is always that of radio-buttons. Notice that each button is labeled with a progressive number. The kout argument is filled with that number when corresponding button is checked.

FLbutBank not only outputs a value but can also activate (or schedule) an instrument provided by the user each time a button is pressed. If the iopcode argument is set to a negative number, no instrument is activated so this feature is optional. In order to activate an instrument, iopcode must be set to 0 or to 105 (the ascii code of character i, referring to the i score opcode). P-fields of the activated instrument are kp1 (instrument number), kp2 (action time), kp3 (duration) and so on with user p-fields.

The itype argument sets the type of buttons identically to the FLbutton opcode. By adding 10 to the itype argument (i.e. by setting 11 for type 1, 12 for type 2, 13 for type 3 and 14 for type 4), it is possible to skip the current FLbutBank value when getting/setting snapshots (see General FLTK Widget-related Opcodes). You can also add 10 to "plastic" button types (31 for type 1, 32 for type 2, etc.)

FLbutBank is very useful to retrieve snapshots.

Examples

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

Example 311. Example of the FLbutBank 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 FLbutton.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
nchnls = 1

FLpanel "Button Bank", 520, 140, 100, 100
    ;itype = 2    ;Light Buttons
    itype = 22    ;Plastic Light Buttons
    inumx = 10
    inumy = 4
    iwidth = 500
    iheight = 120
    ix = 10
    iy = 10
    iopcode = 0
    istarttim = 0
    idur = 1

    gkbutton, ihbb FLbutBank itype, inumx, inumy, iwidth, iheight, ix, iy, iopcode, 1, istarttim, idur

FLpanelEnd
FLrun

instr 1
  ibutton = i(gkbutton)
  prints "Button %i pushed!\\n", ibutton  
endin

</CsInstruments>
<CsScore>

; Real-time performance for 1 hour.
f 0 3600
e


</CsScore>
</CsoundSynthesizer>


See Also

FLbox, FLbutton, FLprintk, FLprintk2, FLvalue

Credits

Author: Gabriel Maldonado

New in version 4.22