rtclock — Read the real time clock from the operating system.


Read the real-time clock from the operating system.


ires rtclock
kres rtclock


Read the real-time clock from operating system. Under Windows, this changes only once per second. Under GNU/Linux, it ticks every microsecond. Performance under other systems varies.


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

Example 408. Example of the rtclock opcode.

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

; 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 rtclock.wav -W ;;; for file output any platform

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

; Instrument #1
instr 1
  ; Get the system time.
  k1 rtclock
  ; Print it once per second.
  printk 1, k1


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


Its output should include lines like this:

 i   1 time     0.00002: 1018236096.00000
 i   1 time     1.00002: 1018236224.00000


Author: John ffitch

Example written by Kevin Conder.

New in version 4.10