<?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>max_k</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="maxalloc.html" title="maxalloc" /> <link rel="next" href="maxtab.html" title="maxtab" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">max_k</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="maxalloc.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="maxtab.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="max_k"> <a id="max_k"></a> <div class="titlepage"></div> <a id="Indexmax_k" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">max_k</span> </h2> <p>max_k — Local maximum (or minimum) value of an incoming asig signal </p> </div> <div class="refsect1" title="Description"> <a id="idp30506008"></a> <h2>Description</h2> <p> <span class="emphasis"><em>max_k</em></span> outputs the local maximum (or minimum) value of the incoming asig signal, checked in the time interval between ktrig has become true twice. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp30506960"></a> <h2>Syntax</h2> <pre class="synopsis">knumkout <span class="command"><strong>max_k</strong></span> asig, ktrig, itype</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp30517416"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>itype</em></span> - itype determinates the behaviour of max_k (see below) </p> </div> <div class="refsect1" title="Performance"> <a id="idp30518296"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>asig</em></span> - incoming (input) signal </p> <p> <span class="emphasis"><em>ktrig</em></span> - trigger signal </p> <p> max_k outputs the local maximum (or minimum) value of the incoming <span class="emphasis"><em>asig</em></span> signal, checked in the time interval between <span class="emphasis"><em>ktrig</em></span> has become true twice. <span class="emphasis"><em>itype</em></span> determinates the behaviour of max_k:</p> <p> 1 - absolute maximum (sign of negative values is changed to positive before evaluation). </p> <p> 2 - actual maximum. </p> <p> 3 - actual minimum. </p> <p> 4 - calculate average value of <span class="emphasis"><em>asig</em></span> in the time interval since the last trigger. </p> <p> This opcode can be useful in several situations, for example to implement a vu-meter. </p> </div> <div class="refsect1" title="Examples"> <a id="idp30557096"></a> <h2>Examples</h2> <p> Here is an example of the max_k opcode. It uses the file <a class="ulink" href="examples/max_k.csd" target="_top"><em class="citetitle">max_k.csd</em></a>. </p> <div class="example"> <a id="idp30557992"></a> <p class="title"> <strong>Example 445. Example of the max_k 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> -odac -Ma <span class="comment">;;;realtime audio out and midi in (on all inputs)</span> <span class="comment">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o max_k.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> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="opc">FLpanel</span> "This Panel contains VU<span class="op">-</span>meter",300,100 gk1,gih1 <span class="opc">FLslider</span> "VU<span class="op">-</span>meter", 0,1,0,1, <span class="op">-</span>1, 250,30, 30,30 <span class="opc">FLsetColor2</span> 50, 50, 255, gih1 <span class="opc">FLpanel_end</span> <span class="opc">FLrun</span> ga1 <span class="opc">init</span> 0 <span class="oblock">instr</span> 1 kenv <span class="opc">linsegr</span> 0,.5,.7,.5,.5,.2,0 ifreq <span class="opc">cpsmidi</span> a1 <span class="opc">poscil</span> <span class="ohdr">0dbfs</span><span class="op">*</span>kenv, ifreq, 1 ga1 <span class="op">=</span> ga1<span class="op">+</span>a1 <span class="oblock">endin</span> <span class="oblock">instr</span> 2 <span class="opc">outs</span> ga1, ga1 ktrig <span class="opc">metro</span> 25 <span class="comment">;refresh 25 times per second</span> kval <span class="opc">max_k</span> ga1, ktrig, 1 <span class="opc">FLsetVal</span> ktrig, kval, gih1 ga1 <span class="op">=</span> 0 <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span>1 0 1024 10 1 <span class="stamnt">i</span>2 0 3600 <span class="stamnt">f</span>0 3600 <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="Credits"> <a id="idp30560264"></a> <h2>Credits</h2> <p>Written by Gabriel Maldonado.</p> <p>New in Csound 5 (Previously available only on CsoundAV)</p> <p>Fixed to agree with documentation in 5.15</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="maxalloc.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="maxtab.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">maxalloc </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> maxtab</td> </tr> </table> </div> </body> </html>