link_metro

link_metro — Returns a trigger that is 1 on the beat and 0 otherwise along with beat, phase, and time for this session of Ableton Link.

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

Returns a trigger that is 1 on the beat and 0 otherwise along with the beat, phase, and current time of Ableton Link for this session for a given quantum.

Syntax

k_trigger, k_beat, k_phase, k_current_time_seconds link_metro i_peer [, k_quantum]

Initialization

i_peer -- The Ableton Link peer object.

Performance

k_trigger -- Trigger, 1 at the instant of the first beat in each local quantum of the beat, and 0 otherwise.

k_beat -- The number of the beat, counting from when this peer is enabled.

k_phase -- The phase of the beat with respect to the quantum.

k_current_time_seconds -- The time of the beat, counting from when this peer is enabled.

k_quantum -- The local quantum of the beat, which may be a multiple or fraction of a beat. The default value is 1.

This opcode permits the use of an Ableton Link session beat to trigger events in Csound. It also can be used to obtain the session time and beat, as well as the phase with respect to the local quantum of the beat. For example, a quantum of 4 can imply 4/4 time, or a quantum of 0.25 will subdivide the beat by 4.

Examples

Here is an example of the link_metro opcode. Play ableton_link.csd

Example 513. Example of the link_metro 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

See the section Ableton Link Opcodes for more information.

Credits

By: Michael Gogins 2017