tempo
Prev | Orchestra Opcodes and Operators | Next

## tempo

tempo — Apply tempo control to an uninterpreted score.

## Description

Apply tempo control to an uninterpreted score.

## Syntax

    tempo ktempo, istartempo

## Initialization

istartempo -- initial tempo (in beats per minute). Typically 60.

## Performance

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.

## Examples

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 374. Example of the tempo opcode.

    /* tempo.orc */
    ; 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 */
    ; 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 */

## See Also

tempoval

## Credits

Example written by Kevin Conder.

Prev | Up | Next
tempest | Home | tempoval