Configurable slider controls for realtime user input. Requires Winsound or TCL/TK. control reads a slider's value.
knum -- number of the slider to be read.
Calling control 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.
Here is an example of the control opcode. It uses the files setctrl.orc and setctrl.sco.
Example 1. Example of the control 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 */
i1 38.00000 i1 40.00000 i1 43.00000