setctrl
Prev | Orchestra Opcodes and Operators | Next

## setctrl

setctrl — Configurable slider controls for realtime user input.

## Description

Plugin opcode in control.

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

Note that this opcode is not available on Windows due to the implimentation of pipes on that system

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 file setctrl.csd.

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

    ; 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

    </CsInstruments>
    <CsScore>

    ; Table #1, a sine wave.
    f 1 0 16384 10 1

    ; Play Instrument #1 for thirty seconds.
    i 1 0 30
    e

    </CsScore>
    </CsoundSynthesizer>

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

Prev | Up | Next
setcol | Home | setksmps