<?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>linlin</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="lineto.html" title="lineto" /> <link rel="next" href="link_beat_force.html" title="link_beat_force" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">linlin</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="lineto.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="link_beat_force.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="linlin"></a> <div class="titlepage"></div> <a id="IndexLinlin" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">linlin</span> </h2> <p>linlin — Linear to linear interpolation </p> </div> <div class="refsect1"> <a id="idm281472920707384"></a> <h2>Description</h2> <p> Maps a linear range of values to another linear range of values. </p> </div> <div class="refsect1"> <a id="idm281472920704152"></a> <h2>Syntax</h2> <pre class="synopsis">kout <span class="command"><strong>linlin</strong></span> kin, ksrclo, ksrchi, kdstlo, kdsthi</pre> </div> <div class="refsect1"> <a id="idm281472920701528"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kin </em></span> -- Input signal </p> <p> <span class="emphasis"><em>ksrclo</em></span> -- Lower limit of input range </p> <p> <span class="emphasis"><em>ksrchi</em></span> -- Higher limit of input range </p> <p> <span class="emphasis"><em>kdstlo</em></span> -- Lower limit of output range </p> <p> <span class="emphasis"><em>kdsthi</em></span> -- Higher limit of output range </p> <p> </p> <pre class="programlisting"> out = (in - srclo) / (srchi - srclo) * (dsthi - dstlo) + dstlo </pre> <p> </p> </div> <div class="refsect1"> <a id="idm281472920624200"></a> <h2>Examples</h2> <p> Here is an example of the linlin opcode. It uses the file <a class="ulink" href="examples/linlin.csd" target="_top"><em class="citetitle">linlin.csd</em></a>. </p> <div class="example"> <a id="idm281472920620952"></a> <p class="title"> <strong>Example 461. Example of the linlin opcode.</strong> </p> <div class="example-contents"> <div class="refsect1"> <a id="idm281472748074456"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></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">128</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="mf">1.0</span> <span class="c1">; Map a value within the range 1-3 to the range 0-10.</span> <span class="kd">instr</span> <span class="nf">1</span> k<span class="n">x</span> <span class="nb">line</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">p3</span><span class="p">,</span> <span class="mi">3</span> k<span class="n">y</span> <span class="nb">linlin</span> k<span class="n">x</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">10</span> <span class="nb">printks</span> <span class="s">"kx: %f ky: %f </span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="mi">1</span><span class="o">/</span><span class="vg">kr</span><span class="p">,</span> k<span class="n">x</span><span class="p">,</span> k<span class="n">y</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</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="idm281472920619192"></a> <h2>See Also</h2> <p> <a class="link" href="scale.html" title="scale"><em class="citetitle">scale</em></a>, <a class="link" href="ntrpol.html" title="ntrpol"><em class="citetitle">ntrpol</em></a>, <a class="link" href="bpf.html" title="bpf"><em class="citetitle">bpf</em></a> </p> </div> <div class="refsect1"> <a id="idm281472920614840"></a> <h2>Credits</h2> <p>By: Eduardo Moguillansky 2017</p> <p>New in version 6.09</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="lineto.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="link_beat_force.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">lineto </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> link_beat_force</td> </tr> </table> </div> </body> </html>