ktempo -- The tempo to which the score will be adjusted.
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.
Here is an example of the tempo opcode. Remember, it only works if you use the -t flag with Csound. The example uses the files tempo.orc and tempo.sco.
Example 1. Example of the tempo opcode.
/* tempo.orc */
/* Written by Kevin Conder */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1.
instr 1
; If the fourth p-field is 1, increase the tempo.
if (p4 == 1) kgoto speedup
kgoto playit
speedup:
; Increase the tempo to 150 beats per minute.
tempo 150, 60
playit:
a1 oscil 10000, 440, 1
out a1
endin
/* tempo.orc */
/* tempo.sco */
/* Written by Kevin Conder */
; Table #1, a sine wave.
f 1 0 16384 10 1
; p4 = plays at a faster tempo (when p4=1).
; Play Instrument #1 at the normal tempo, repeat 3 times.
r3
i 1 00.00 00.10 0
i 1 00.25 00.10 0
i 1 00.50 00.10 0
i 1 00.75 00.10 0
s
; Play Instrument #1 at a faster tempo, repeat 3 times.
r3
i 1 00.00 00.10 1
i 1 00.25 00.10 1
i 1 00.50 00.10 1
i 1 00.75 00.10 1
s
e
/* tempo.sco */