<?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>vaset</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="valpass.html" title="valpass" /> <link rel="next" href="vbap.html" title="vbap" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">vaset</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="valpass.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="vbap.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="vaset"> <a id="vaset"></a> <div class="titlepage"></div> <a id="IndexAvarSet" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">vaset</span> </h2> <p>vaset — Write value of into the current buffer of an a-rate variable by index. </p> </div> <div class="refsect1" title="Description"> <a id="idp50182504"></a> <h2>Description</h2> <p> Write values into the current buffer of an a-rate variable at the given index. Useful for doing sample-by-sample manipulation at k-rate without using setksmps 1. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: 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>Because this opcode does not do any bounds checking, the user must be careful not to try to write values past ksmps (the size of a buffer for an a-rate variable) by using index values greater than ksmps.</p> </td> </tr> </table> </div> <p> </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: 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>In Csound6 this opcode does do bounds checking.</p> </td> </tr> </table> </div> <p> </p> </div> <div class="refsect1" title="Syntax"> <a id="idp50184712"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>vaset</strong></span> kval, kndx, avar</pre> </div> <div class="refsect1" title="Performance"> <a id="idp50237992"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kval</em></span> - value to write into avar </p> <p> <span class="emphasis"><em>kndx</em></span> - index of the sample to write to the current buffer of the given avar variable </p> <p> <span class="emphasis"><em>avar</em></span> - a-rate variable to write to </p> </div> <div class="refsect1" title="Examples"> <a id="idp50239752"></a> <h2>Examples</h2> <p> Here is an example of the vaset opcode. It uses the file <a class="ulink" href="examples/vaset.csd" target="_top"><em class="citetitle">vaset.csd</em></a>. </p> <div class="example"> <a id="idp50240720"></a> <p class="title"> <strong>Example 919. Example of the vaset 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 No messages</span> -odac -iadc -d <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 avarset.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span><span class="op">=</span>44100 <span class="ohdr">ksmps</span><span class="op">=</span>1 <span class="ohdr">nchnls</span><span class="op">=</span>2 <span class="oblock">instr</span> 1 <span class="comment">; Sine Wave</span> ifreq <span class="op">=</span> (p4 <span class="op">></span> 15 <span class="op">?</span> p4 <span class="op">:</span> <span class="opc">cpspch</span>(p4)) iamp <span class="op">=</span> <span class="opc">ampdb</span>(p5) kenv <span class="opc">adsr</span> 0.1, 0.05, .9, 0.2 aout <span class="opc">init</span> 0 ksampnum <span class="opc">init</span> 0 kcount <span class="op">=</span> 0 iperiod <span class="op">=</span> <span class="ohdr">sr</span> <span class="op">/</span> ifreq i2pi <span class="op">=</span> 3.14159 <span class="op">*</span> 2 <span class="olabel">loopStart</span><span class="op">:</span> kphase <span class="op">=</span> (ksampnum <span class="op">%</span> iperiod) <span class="op">/</span> iperiod knewval <span class="op">=</span> <span class="opc">sin</span>(kphase <span class="op">*</span> i2pi) <span class="opc">vaset</span> knewval, kcount,aout ksampnum <span class="op">=</span> ksampnum <span class="op">+</span> 1 <span class="octrl">loop_lt</span> kcount, 1, ksmps, <span class="olabel">loopStart</span> aout <span class="op">=</span> aout <span class="op">*</span> iamp <span class="op">*</span> kenv <span class="opc">outs</span> aout, aout <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span>1 0.0 2 440 80 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="idp50242992"></a> <h2>See Also</h2> <p> <a class="link" href="vaget.html" title="vaget"><em class="citetitle">vaget</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp50244008"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Steven Yi</td> </tr> </table> <p> </p> <p>New in version 5.04</p> <p>September 2006.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="valpass.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="vbap.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">valpass </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> vbap</td> </tr> </table> </div> </body> </html>