| 1 | |
| 2 | <refentry id="timek"> |
| 3 | <indexterm id="IndexTimek"><primary>timek</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Time Reading</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>timek</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>timek</refname> |
| 11 | <refpurpose> |
| 12 | Read absolute time in k-rate cycles. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Read absolute time, in k-rate cycles, since the start of the performance. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>ires <command>timek</command></synopsis> |
| 26 | |
| 27 | <synopsis>kres <command>timek</command></synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Performance</title> |
| 32 | <para> |
| 33 | <emphasis>timek</emphasis> is for time in k-rate cycles. So with: |
| 34 | |
| 35 | <informalexample> |
| 36 | <programlisting> |
| 37 | <emphasis role="opc">sr</emphasis> <emphasis role="op">=</emphasis> 44100 |
| 38 | <emphasis role="opc">kr</emphasis> <emphasis role="op">=</emphasis> 6300 |
| 39 | <emphasis role="opc">ksmps</emphasis> <emphasis role="op">=</emphasis> 7</programlisting> |
| 40 | </informalexample> |
| 41 | |
| 42 | then after half a second, the <emphasis>timek</emphasis> opcode would report 3150. It will always report an integer. |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>timek</emphasis> can produce a k-rate variable for output. There are no input parameters. |
| 47 | </para> |
| 48 | |
| 49 | <para> |
| 50 | <emphasis>timek</emphasis> can also operate only at the start of the instance of the instrument. It produces an i-rate variable (starting with <emphasis>i</emphasis> or <emphasis>gi</emphasis>) as its output. |
| 51 | </para> |
| 52 | </refsect1> |
| 53 | |
| 54 | <refsect1> |
| 55 | <title>Examples</title> |
| 56 | <para> |
| 57 | Here is an example of the timek opcode. It uses the file <ulink url="examples/timek.csd"><citetitle>timek.csd</citetitle></ulink>. |
| 58 | |
| 59 | <example> |
| 60 | <title>Example of the timek opcode.</title> |
| 61 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 62 | <xi:include href="examples-xml/timek.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 63 | </example> |
| 64 | |
| 65 | Its output should include lines like this: |
| 66 | <screen> |
| 67 | k1 = 1.000000 samples |
| 68 | k1 = 2205.000000 samples |
| 69 | k1 = 4410.000000 samples |
| 70 | k1 = 6615.000000 samples |
| 71 | k1 = 8820.000000 samples</screen> |
| 72 | </para> |
| 73 | </refsect1> |
| 74 | |
| 75 | <refsect1> |
| 76 | <title>See also</title> |
| 77 | <para><link linkend="ControlTimeread"><citetitle>Time Reading</citetitle></link></para> |
| 78 | </refsect1> |
| 79 | |
| 80 | <refsect1> |
| 81 | <title>Credits</title> |
| 82 | <para> |
| 83 | <simplelist> |
| 84 | <member>Author: Robin Whittle</member> |
| 85 | <member>Australia</member> |
| 86 | <member>May 1997</member> |
| 87 | </simplelist> |
| 88 | </para> |
| 89 | <para>New in version 3.47</para> |
| 90 | <para>Example written by &namekevin;.</para> |
| 91 | </refsect1> |
| 92 | </refentry> |