link_tempo_set
Prev | Orchestra Opcodes and Operators | Next

## link_tempo_set

link_tempo_set — Sets the tempo.

## Description

Plugin opcode in ableton_link_opcodes. This opcode is part of the plugin repository and has to be installed separately. The plugin repository can be found here: https://github.com/csound/plugins

Sets the local tempo if this peer is not enabled; sets the tempo of the global network Ableton Link session if this peer is enabled.

## Syntax

    link_tempo_set i_peer, k_bpm [, k_at_time_seconds]

## Initialization

i_peer -- The Ableton Link peer object.

k_bpm -- The requested tempo in beats per minute.

k_at_time_seconds -- The session time at which the indicated tempo will take effect. The default value is the current session time.

## Examples

Here is an example of the link_tempo_set opcode. It uses the file ableton_link.csd.

Example 518. Example of the link_tempo_set opcode.

    <CsoundSynthesizer>
    <CsLicense>
    Run the Ableton Link "LinkHut" example application, or some other
    Ableton Link peer, while you run this CSD to see what happens.
    </CsLicense>
    <CsOptions>
    -m0 -d -odac
    </CsOptions>
    <CsInstruments>
    sr = 44100
    ksmps = 10
    nchnls = 2

    alwayson "LinkMonitor"

    gi_peer link_create 72
    gk_beat init 0

    instr Beep
    asignal oscils 20000, p4, 0
    outs asignal, asignal
    endin

    instr TempoChange
    link_tempo_set gi_peer, 80
    endin

    instr LinkEnable
    i_enabled = p4
    link_enable gi_peer, i_enabled
    endin

    instr LinkMonitor
    i_kperiod_seconds = ksmps / sr
    printf_i "kperiod: %9.6f seconds.\n", 1, i_kperiod_seconds
    printf_i "gi_peer: %g\n", 1, gi_peer
    link_enable gi_peer, 1
    k_trigger, gk_beat, k_phase, k_time link_metro gi_peer, 1
    k_peers link_peers gi_peer
    k_tempo link_tempo_get gi_peer
    k_enabled link_is_enabled gi_peer
    k_hz = 1000
    if floor(gk_beat % 4) == 0 then
    k_hz = 3000
    else
    k_hz = 2000
    endif
    schedkwhen k_trigger, 0, 1, "Beep", 0, 0.01, k_hz
    printf "LinkMonitor: gi_peer: %g k_enabled: %9.4f k_trigger: %9.4f beat: %9.4f k_phase: %9.4f time: %9.4f tempo: %9.4f peers: %3d\n", k_trigger, gi_peer, k_enabled, k_trigger, gk_beat, k_phase, k_time, k_tempo, k_peers
    endin
    </CsInstruments>
    <CsScore>
    f 0 360
    i "TempoChange" 10 80
    i "LinkEnable"  20 1 0
    i "LinkEnable"  30 1 1
    </CsScore>
    </CsoundSynthesizer>

## See also

Ableton Link Opcodes

## Credits

By: Michael Gogins 2017

Prev | Up | Next
link_tempo_get | Home | linrand