<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>timek</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="timeinsts.html" title="timeinsts" /> <link rel="next" href="times.html" title="times" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">timek</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="timeinsts.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="times.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="timek"> <a id="timek"></a> <div class="titlepage"></div> <a id="IndexTimek" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">timek</span> </h2> <p>timek — Read absolute time in k-rate cycles. </p> </div> <div class="refsect1" title="Description"> <a id="idp48945336"></a> <h2>Description</h2> <p> Read absolute time, in k-rate cycles, since the start of the performance. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp48946024"></a> <h2>Syntax</h2> <pre class="synopsis">ires <span class="command"><strong>timek</strong></span></pre> <pre class="synopsis">kres <span class="command"><strong>timek</strong></span></pre> </div> <div class="refsect1" title="Performance"> <a id="idp48988120"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>timek</em></span> is for time in k-rate cycles. So with: </p> <div class="informalexample"> <pre class="programlisting"> <span class="opc">sr</span> <span class="op">=</span> 44100 <span class="opc">kr</span> <span class="op">=</span> 6300 <span class="opc">ksmps</span> <span class="op">=</span> 7</pre> </div> <p> then after half a second, the <span class="emphasis"><em>timek</em></span> opcode would report 3150. It will always report an integer. </p> <p> <span class="emphasis"><em>timek</em></span> can produce a k-rate variable for output. There are no input parameters. </p> <p> <span class="emphasis"><em>timek</em></span> can also operate only at the start of the instance of the instrument. It produces an i-rate variable (starting with <span class="emphasis"><em>i</em></span> or <span class="emphasis"><em>gi</em></span>) as its output. </p> </div> <div class="refsect1" title="Examples"> <a id="idp48993224"></a> <h2>Examples</h2> <p> Here is an example of the timek opcode. It uses the file <a class="ulink" href="examples/timek.csd" target="_top"><em class="citetitle">timek.csd</em></a>. </p> <div class="example"> <a id="idp48994192"></a> <p class="title"> <strong>Example 882. Example of the timek opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> <span class="comment">; Audio out Audio in</span> -odac -iadc <span class="comment">;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o timek.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; Initialize the global variables.</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 4410 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="comment">; Instrument #1.</span> <span class="oblock">instr</span> 1 <span class="comment">; Print out the value from timek every half-second.</span> k1 <span class="opc">timek</span> <span class="opc">printks</span> "k1 <span class="op">=</span> <span class="op">%</span>f samples\\n", 0.5, k1 <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Play Instrument #1 for two seconds.</span> <span class="stamnt">i</span> 1 0 2 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> Its output should include lines like this: </p> <pre class="screen"> k1 = 1.000000 samples k1 = 2205.000000 samples k1 = 4410.000000 samples k1 = 6615.000000 samples k1 = 8820.000000 samples</pre> <p> </p> </div> <div class="refsect1" title="See Also"> <a id="idp48996968"></a> <h2>See Also</h2> <p> <a class="link" href="timeinstk.html" title="timeinstk"><em class="citetitle">timeinstk</em></a>, <a class="link" href="timeinsts.html" title="timeinsts"><em class="citetitle">timensts</em></a>, <a class="link" href="times.html" title="times"><em class="citetitle">times</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp48998936"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Robin Whittle</td> </tr> <tr> <td>Australia</td> </tr> <tr> <td>May 1997</td> </tr> </table> <p> </p> <p>New in version 3.47</p> <p>Example written by Kevin Conder.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="timeinsts.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="times.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">timeinsts </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> times</td> </tr> </table> </div> </body> </html>