<?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>schedwhen</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <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="schedule.html" title="schedule" /> <link rel="next" href="scoreline.html" title="scoreline" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">schedwhen</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="schedule.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="scoreline.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="schedwhen"></a> <div class="titlepage"></div> <a id="IndexSchedwhen" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">schedwhen</span> </h2> <p>schedwhen — Adds a new score event. </p> </div> <div class="refsect1"> <a id="idm281472893102312"></a> <h2>Description</h2> <p> Adds a new score event. </p> </div> <div class="refsect1"> <a id="idm281472893058840"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>schedwhen</strong></span> ktrigger, kinsnum, kwhen, kdur [, ip4] [, ip5] [...]</pre> <pre class="synopsis"><span class="command"><strong>schedwhen</strong></span> ktrigger, "insname", kwhen, kdur [, ip4] [, ip5] [...]</pre> </div> <div class="refsect1"> <a id="idm281472893055432"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ip4, ip5, ...</em></span> -- Equivalent to p4, p5, etc., in a score <a class="link" href="i.html" title="i Statement (Instrument or Note Statement)"><em class="citetitle">i statement</em></a>. </p> </div> <div class="refsect1"> <a id="idm281472893052840"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kinsnum</em></span> -- instrument number. Equivalent to p1 in a score <a class="link" href="i.html" title="i Statement (Instrument or Note Statement)"><em class="citetitle">i statement</em></a>. </p> <p> <span class="emphasis"><em><span class="quote">“<span class="quote">insname</span>”</span></em></span> -- A string (in double-quotes) representing a named instrument. </p> <p> <span class="emphasis"><em>ktrigger</em></span> -- trigger value for new event </p> <p> <span class="emphasis"><em>kwhen</em></span> -- start time of the new event. Equivalent to p2 in a score <a class="link" href="i.html" title="i Statement (Instrument or Note Statement)"><em class="citetitle">i statement</em></a>. </p> <p> <span class="emphasis"><em>kdur</em></span> -- duration of event. Equivalent to p3 in a score <a class="link" href="i.html" title="i Statement (Instrument or Note Statement)"><em class="citetitle">i statement</em></a>. </p> <p> <span class="emphasis"><em>schedwhen</em></span> adds a new score event. The event is only scheduled when the k-rate value <span class="emphasis"><em>ktrigger</em></span> is first non-zero. The arguments, including options, are the same as in a score. The <span class="emphasis"><em>kwhen</em></span> time (p2) is measured from the time of this event. </p> <p> If the duration is zero or negative the new event is of MIDI type, and inherits the release sub-event from the scheduling instruction. </p> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> Note that the <span class="emphasis"><em>schedwhen</em></span> opcode can't accept string p-fields. If you need to pass strings when instantiating an instrument, use the <a class="link" href="scoreline.html" title="scoreline"><em class="citetitle">scoreline</em></a> or <a class="link" href="scoreline_i.html" title="scoreline_i"><em class="citetitle">scoreline_i</em></a> opcode.</p> </td> </tr> </table> </div> </div> <div class="refsect1"> <a id="idm281472893038680"></a> <h2>Examples</h2> <p> Here is an example of the schedwhen opcode. It uses the file <a class="ulink" href="examples/schedwhen.csd" target="_top"><em class="citetitle">schedwhen.csd</em></a>. </p> <div class="example"> <a id="idm281472893036824"></a> <p class="title"> <strong>Example 857. Example of the schedwhen 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> <div class="refsect1"> <a id="idm281472713561672"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac <span class="c1">;;;realtime audio out</span> <span class="c1">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o schedwhen.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="vg">0dbfs</span> <span class="o">=</span> <span class="mi">1</span> <span class="kd">instr</span> <span class="nf">1</span> k<span class="n">mtr</span> <span class="nb">metro</span> <span class="mi">100</span> <span class="c1">;produce 100 triggers per second</span> <span class="nb">schedwhen</span> k<span class="n">mtr</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">.3</span> <span class="c1">;but schedwhen plays instr. 2 only once </span> <span class="kd">endin</span> <span class="kd">instr</span> <span class="nf">2</span> a<span class="n">env</span> <span class="nb">linseg</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">p3</span><span class="o">*</span><span class="mf">.1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">p3</span><span class="o">*</span><span class="mf">.3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">p3</span><span class="o">*</span><span class="mf">.6</span><span class="p">,</span> <span class="mi">0</span> <span class="c1">;envelope</span> a<span class="n">1</span> <span class="nb">poscil</span> <span class="mf">.3</span><span class="o">*</span>a<span class="n">env</span><span class="p">,</span> <span class="mi">1000</span><span class="p">,</span> <span class="mi">1</span> <span class="nb">outs</span> a<span class="n">1</span><span class="p">,</span> a<span class="n">1</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">f</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">16384</span> <span class="mi">10</span> <span class="mi">1</span> <span class="c1">;sine </span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">3</span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">3</span> <span class="mi">5</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1"> <a id="idm281472893032536"></a> <h2>See also</h2> <p><a class="link" href="event.html" title="event"><em class="citetitle">event</em></a>, <a class="link" href="event_i.html" title="event_i"><em class="citetitle">event_i</em></a>, <a class="link" href="schedule.html" title="schedule"><em class="citetitle">schedule</em></a>, <a class="link" href="schedkwhen.html" title="schedkwhen"><em class="citetitle">schedkwhen</em></a>, <a class="link" href="schedkwhennamed.html" title="schedkwhennamed"><em class="citetitle">schedkwhennamed</em></a>, <a class="link" href="scoreline.html" title="scoreline"><em class="citetitle">scoreline</em></a>, <a class="link" href="scoreline_i.html" title="scoreline_i"><em class="citetitle">scoreline_i</em></a></p> </div> <div class="refsect1"> <a id="idm281472893024984"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: John ffitch</td> </tr> <tr> <td>University of Bath/Codemist Ltd.</td> </tr> <tr> <td>Bath, UK</td> </tr> <tr> <td>November 1998</td> </tr> </table> <p> </p> <p>New in Csound version 3.491</p> <p>Based on work by Gabriel Maldonado</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="schedule.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="scoreline.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">schedule </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> scoreline</td> </tr> </table> </div> </body> </html>