timek

timek — Read absolute time in k-rate cycles.

Description

Read absolute time, in k-rate cycles, since the start of the performance.

Syntax

ires timek
kres timek

Performance

timek is for time in k-rate cycles. So with:

  sr    = 44100
  kr    = 6300
  ksmps = 7

then after half a second, the timek opcode would report 3150. It will always report an integer.

timek can produce a k-rate variable for output. There are no input parameters.

timek can also operate only at the start of the instance of the instrument. It produces an i-rate variable (starting with i or gi) as its output.

Examples

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

Example 904. Example of the timek 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 timek.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
  ; Print out the value from timek every half-second.
  k1 timek
  printks "k1 = %f samples\\n", 0.5, k1
endin


</CsInstruments>
<CsScore>

; Play Instrument #1 for two seconds.
i 1 0 2
e


</CsScore>
</CsoundSynthesizer>


Its output should include lines like this:

k1 = 1.000000 samples
k1 = 2205.000000 samples
k1 = 4410.000000 samples
k1 = 6615.000000 samples
k1 = 8820.000000 samples

See Also

timeinstk, timensts, times

Credits

Author: Robin Whittle
Australia
May 1997

New in version 3.47

Example written by Kevin Conder.