Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2161

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>lua_exec</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="lpslot.html" title="lpslot" />
    <link rel="next" href="lua_opdef.html" title="lua_opdef" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">
            lua_exec
        </th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="lpslot.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="lua_opdef.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="lua_exec">
      <a id="lua_exec"></a>
      <div class="titlepage"></div>
      <a id="Indexlua_exec" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">
            lua_exec
        </span>
        </h2>
        <p>
            lua_exec
         — 
            Executes an arbitrary block of Lua code from the Csound orchestra.
        </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp29947920"></a>
        <h2>
            Description
        </h2>
        <p>
            Executes an arbitrary block of Lua code from the Csound orchestra. 
            The code is executed at initialization time, typically from the 
            orchestra header. 
        </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp29948744"></a>
        <h2>
            Syntax
        </h2>
        <pre class="synopsis"><span class="command"><strong>lua_exec</strong></span> Sluacode</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp29959176"></a>
        <h2>
            Initialization
        </h2>
        <p>
            <span class="emphasis"><em>Sluacode</em></span> -- A block of Lua code, of any 
            length. Multi-line blocks may be enclosed in 
            double braces (i.e. <code class="literal">{{ }}</code>). This code is 
            evaluated once at initialization time, typically from the 
            orchestra header. Global and local variables, functions, 
            tables, and classes may be declared and defined. Objects defined 
            at global Lua scope remain in scope throughout the performance, 
            and are visible to any other Lua code in the same Csound thread.
        </p>
        <p>
            The running instance of Csound is stored as a 
            Lua lightuserdata in a global variable <code class="literal">csound</code>. 
            This can be passed to any Csound API function.  One use of this 
            would be to generate a score using Lua in the orchestra header, 
            and schedule the events for performance using <code class="literal">csoundInputMessage</code>.
        </p>
        <div class="note" title="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>
               By default, all objects defined in Lua are defined at global 
               scope. In order to ensure that objects are confined to their 
               own block of code, that is to ensure that the object is visible 
               only in lexical scope, the object must be declared as local. 
               This is the feature of Lua that beginners tend to find the most 
               troublesome.
            </p>
                <p>
               Another thing to look out for is that Lua arrays use 1-based 
               indexing, not the 0-based indexing used in C and many other 
               programming languages.
            </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp30018840"></a>
        <h2>
            See Also
        </h2>
        <p>
            <a class="link" href="lua_opdef.html" title="lua_opdef"><em class="citetitle">lua_opdef</em></a>, 
            <a class="link" href="lua_opcall.html" title="lua_opcall"><em class="citetitle">lua_opcall</em></a>. 
        </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp30020424"></a>
        <h2>
            Credits
        </h2>
        <p>
            By: Michael Gogins 2011
        </p>
        <p>
            New in Csound version 5.13.2
        </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="lpslot.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="lua_opdef.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">lpslot </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> 
            lua_opdef
        </td>
        </tr>
      </table>
    </div>
  </body>
</html>