The Public Csound Reference Manual Version 4.10 Instrument Control: Sensing and Control Page 11-10
11.7 x y i n , t e m p o
kx, ky xyinxyinxyinxyin iprd, ixmin, ixmax, iymin, iymax[, ixinit, iyinit]
tempo tempo tempo
tempo ktempo, istartempo
D
ESCRIPTIONSense the cursor position in an output window. Apply tempo control to an uninterpreted score. When xyin is called the position of the mouse within the output window is used to reply to the request. This simple mechanism does mean that only one xyin can be used accurately at once. The position of the mouse is reported in the output window.
I
NITIALIZATIONiprd- period of cursor sensing (in seconds). Typically .1 seconds.
xmin, xmax, ymin, ymax – edge values for the x-y coordinates of a cursor in the input window.
ixinit, iyinit (optional) – initial x-y coordinates reported; the default values are 0,0. If these values are not within the given min-max range, they will be coerced into that range.
istartempo – initial tempo (in beats per minute). Typically 60.
P
ERFORMANCExyin samples the cursor x-y position in an input window every iprd seconds. Output values are repeated (not interpolated) at the k-rate, and remain fixed until a new change is registered in the window. There may be any number of input windows. This unit is useful for real-time control, but continuous motion should be avoided if iprd is unusually small.
tempo allows the performance speed of Csound scored events to be controlled from within an orchestra. It operates only in the presence of the Csound -t flag. When that flag is set, scored events will be performed from their uninterpreted p2 and p3 (beat) parameters, initially at the given command-line tempo. When a tempo statement is activated in any instrument (ktempo 0.), the operating tempo will be adjusted to ktempo beats per minute.
There may be any number of tempo statements in an orchestra, but coincident activation is best avoided.
The Public Csound Reference Manual Version 4.10 Instrument Control: Sensing and Control Page 11-11
11.8 f o l l o w2
ar follow2follow2follow2follow2 asig, katt, krel
D
ESCRIPTIONA controllable envelope extractor using the algorithm attributed to Jean-Marc Jot.
P
ERFORMANCEasig – the input signal whose envelope is followed katt – the attack rate (60dB attack time in seconds) krel – the decay rate (60dB decay time in seconds)
The output tracks the amplitude envelope of the input signal. The rate at which the output grows to follow the signal is controlled by the katt, and the rate at which it decreases in response to a lower amplitude, is controlled by the krel. This gives a smoother envelope than follow.
E
XAMPLEa1 follow2follow2follow2follow2 ain, 0.01, .1
A
UTHORJohn ffitch
University of Bath, Codemist Ltd.
Bath, UK February, 2000
New in Csound version 4.03
The Public Csound Reference Manual Version 4.10 Instrument Control: Sensing and Control Page 11-12
11.9 s e t c t r l , c o n tr o l
setctrl setctrl setctrl
setctrl inum, kval, itype kout controlcontrolcontrolcontrol knum
D
ESCRIPTIONConfigurable 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.
control reads a slider's value.
I
NITIALIZATIONinum – number of the slider to set
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)
P
ERFORMANCEkval – value to be sent to the slider
Calling setctrl or 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.
E
XAMPLE#define SLIDERNUM # 6 # instr
instr instr instr 1 kgoto kgoto kgoto
kgoto continue ; We don't want to configure sliders at ; rate!
; Set min=10, max=1000, actual=20
setctrlsetctrlsetctrlsetctrl $SLIDERNUM., 20, 0 setctrlsetctrlsetctrlsetctrl $SLIDERNUM., 10, 1 setctrlsetctrlsetctrlsetctrl $SLIDERNUM., 1000, 2 continue:
kcHz controlcontrolcontrolcontrol $SLIDERNUM. ; Read values with smoothing kcHz portportportport kcHz, .02
; ... etc endin endin endin endin
A
UTHORJohn ffitch
University of Bath, Codemist. Ltd.
Bath, UK July, 2000
New in Csound version 4.06
The Public Csound Reference Manual Version 4.10 Instrument Control: Sensing and Control Page 11-13
11.10 b u t t o n , ch e ck b o x
kr buttonbuttonbuttonbutton inum kr checkboxcheckboxcheckboxcheckbox inum
D
ESCRIPTIONSense on-screen controls. Needs Windows or TCL/TK.
I
NITIALIZATIONinum – the number of the button or checkbox. If it does not exist, it is made on-screen at initialization.
P
ERFORMANCEIf the button has been pushed since the last k-period, then return 1, otherwise return 0. If the checkbox is set (pushed) then return 1, if not, return 0.
E
XAMPLEIncrease pitch while a checkbox is set, and extend duration for each push of a button.
instr instr instr instr 1
kcps = cpsoct(p5) k1 checkcheckcheckcheck 1
if if if
if (k1 == 1) kcps = kcps * 1.1 a1 osciloscilosciloscil p4, kcps, 1
out out out out a1 k2 buttonbuttonbuttonbutton 1
ifif
ifif (k2 == 1) p3 = p3 + 0.1 endin
endin endin endin
A
UTHORJohn ffitch
University of Bath, Codemist Ltd.
Bath, UK
September, 2000
New in Csound version 4.08
The Public Csound Reference Manual Version 4.10 Instrument Control: Sensing and Control Page 11-14
11.11 s en s e k e y
kr sensekeysensekeysensekeysensekey
D
ESCRIPTIONReturns the ASCII code of a key that has been pressed, or -1 if no key has been pressed.
P
ERFORMANCEAt release, this has not been properly verified, and seems not to work at all on Windows.
A
UTHORJohn ffitch
University of Bath, Codemist. Ltd.
Bath, UK October, 2000
New in Csound version 4.09
The Public Csound Reference Manual Version 4.10 Instrument Control: Conditional Values Page 12-1