Sophie

Sophie

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

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>Orchestra Syntax</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="py.html" title="Python Opcodes" />
    <link rel="prev" href="py.html" title="Python Opcodes" />
    <link rel="next" href="ImageopcodesTop.html" title="Image processing opcodes" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Orchestra Syntax</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="py.html">Prev</a> </td>
          <th width="60%" align="center">Python Opcodes</th>
          <td width="20%" align="right"> <a accesskey="n" href="ImageopcodesTop.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="section" title="Orchestra Syntax">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="PythonOpcodesSyntax"></a>Orchestra Syntax</h2>
          </div>
        </div>
      </div>
      <p>Blocks of Python code, and indeed entire scripts, can be
    embedded in Csound orchestras using the {{ and }} directives to
    enclose the script, as follows:</p>
      <pre class="programlisting">
<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="opc">pyinit</span>

giSinusoid	<span class="opc">ftgen</span>	0,	0, 8192, 10,	1

<span class="opc">pyruni</span> {{
import random

pool = [(1 + i/10.0) ** 1.2 for i in range(100)]

def get_number_from_pool(n, p):
    if random.random() &lt; p:
        i = int(random.random() * len(pool))
        pool[i] = n
    return random.choice(pool)
}}

<span class="oblock">instr</span> 1
	k1	<span class="opc">oscil</span>	1, 3, giSinusoid	
	k2	<span class="opc">pycall1</span>	"get_number_from_pool", k1 <span class="op">+</span> 2, p4
		<span class="opc">printk</span>	0.01, k2
<span class="oblock">endin</span></pre>
      <h3><a id="idp12107920"></a>Credits</h3>
      <p>Copyright (c) 2002 by Maurizio Umberto Puxeddu. All rights
  reserved.</p>
      <p>Portions copyright (c) 2004 and 2005 by Michael Gogins.</p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="py.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="py.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ImageopcodesTop.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Python Opcodes </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Image processing opcodes</td>
        </tr>
      </table>
    </div>
  </body>
</html>