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 file tempo.csd.

Example 505. Example of the tempo opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o tempo.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      kval tempoval

      printk 0.1, kval

      ; 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

    </CsInstruments>
    <CsScore>

    ; 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.25 0
    i 1 00.25 00.25 0
    i 1 00.50 00.25 0
    i 1 00.75 00.25 0
    s

    ; Play Instrument #1 at a faster tempo, repeat 3 times.
    r3
    i 1 00.00 00.25 1
    i 1 00.25 00.25 0
    i 1 00.50 00.25 0
    i 1 00.75 00.25 0
    s

    e

    </CsScore>
    </CsoundSynthesizer>

## See Also

tempoval

## Credits

Example written by Kevin Conder.

Prev | Up | Next
tempest | Home | tempoval