The Alternative Csound Reference Manual
Previous |  | Next

# setctrl

setctrl -- Configurable slider controls for realtime user input.

## Description

Configurable slider controls for realtime user input. Requires Winsound or TCL/TK. setctrl sets a slider to a specific value, or sets a minimum or maximum range.

## Syntax

setctrl inum, ival, itype

## Initialization

inum -- number of the slider to set

ival -- value to be sent to the slider

itype -- type of value sent to the slider as follows:

- 1 -- set the current value. Initial value is 0.

- 2 -- set the minimum value. Default is 0.

- 3 -- set the maximum value. Default is 127.

- 4 -- set the label. (New in Csound version 4.09)

## Performance

Calling setctrl will create a new slider on the screen. There is no theoretical limit to the number of sliders. Windows and TCL/TK use only integers for slider values, so the values may need rescaling. GUIs usually pass values at a fairly slow rate, so it may be advisable to pass the output of control through port.

## Examples

Here is an example of the setctrl opcode. It uses the files setctrl.orc and setctrl.sco.

Example 1. Example of the setctrl opcode.

    /* setctrl.orc */
    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Display the label "Volume" on Slider #1.
      setctrl 1, "Volume", 4
      ; Set Slider #1's initial value to 20.
      setctrl 1, 20, 1

      ; Capture and display the values for Slider #1.
      k1 control 1
      printk2 k1

      ; Play a simple oscillator.
      ; Use the values from Slider #1 for amplitude.
      kamp = k1 * 128
      a1 oscil kamp, 440, 1
      out a1
    endin
    /* setctrl.orc */

    /* setsctrl.sco */
    ; Table #1, a sine wave.
    f 1 0 16384 10 1

    ; Play Instrument #1 for thirty seconds.
    i 1 0 30
    e
    /* setsctrl.sco */

Its output should include lines like this:

     i1    38.00000
     i1    40.00000
     i1    43.00000

## See Also

control

## Credits

Author: John ffitch
University of Bath, Codemist. Ltd.
Bath, UK
May 2000

Example written by Kevin Conder.

New in Csound version 4.06

Previous | Home | Next
seqtime | Up | setksmps