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:

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 */
/* Written by Kevin Conder */
; 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 */
/* Written by Kevin Conder */
; 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

New in Csound version 4.06