<?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>svfilter</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="sumtab.html" title="sumtab" /> <link rel="next" href="syncgrain.html" title="syncgrain" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">svfilter</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="sumtab.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="syncgrain.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="svfilter"> <a id="svfilter"></a> <div class="titlepage"></div> <a id="IndexSvfilter" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">svfilter</span> </h2> <p>svfilter — A resonant second order filter, with simultaneous lowpass, highpass and bandpass outputs. </p> </div> <div class="refsect1" title="Description"> <a id="idp46830992"></a> <h2>Description</h2> <p> Implementation of a resonant second order filter, with simultaneous lowpass, highpass and bandpass outputs. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp46856840"></a> <h2>Syntax</h2> <pre class="synopsis">alow, ahigh, aband <span class="command"><strong>svfilter</strong></span> asig, kcf, kq [, iscl]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp46857968"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>iscl</em></span> -- coded scaling factor, similar to that in <a class="link" href="reson.html" title="reson"><em class="citetitle">reson</em></a>. A non-zero value signifies a peak response factor of 1, i.e. all frequencies other than <span class="emphasis"><em>kcf</em></span> are attenuated in accordance with the (normalized) response curve. A zero value signifies no scaling of the signal, leaving that to some later adjustment (see <a class="link" href="balance.html" title="balance"><em class="citetitle">balance</em></a>). The default value is 0. </p> </div> <div class="refsect1" title="Performance"> <a id="idp46860304"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>svfilter</em></span> is a second order state-variable filter, with k-rate controls for cutoff frequency and Q. As Q is increased, a resonant peak forms around the cutoff frequency. <span class="emphasis"><em>svfilter</em></span> has simultaneous lowpass, highpass, and bandpass filter outputs; by mixing the outputs together, a variety of frequency responses can be generated. The state-variable filter, or "multimode" filter was a common feature in early analog synthesizers, due to the wide variety of sounds available from the interaction between cutoff, resonance, and output mix ratios. <span class="emphasis"><em>svfilter</em></span> is well suited to the emulation of "analog" sounds, as well as other applications where resonant filters are called for. </p> <p> <span class="emphasis"><em>asig</em></span> -- Input signal to be filtered. </p> <p> <span class="emphasis"><em>kcf</em></span> -- Cutoff or resonant frequency of the filter, measured in Hz. </p> <p> <span class="emphasis"><em>kq</em></span> -- Q of the filter, which is defined (for bandpass filters) as bandwidth/cutoff. <span class="emphasis"><em>kq</em></span> should be in a range between 1 and 500. As <span class="emphasis"><em>kq</em></span> is increased, the resonance of the filter increases, which corresponds to an increase in the magnitude and "sharpness" of the resonant peak. When using <span class="emphasis"><em>svfilter</em></span> without any scaling of the signal (where <span class="emphasis"><em>iscl</em></span> is either absent or 0), the volume of the resonant peak increases as Q increases. For high values of Q, it is recommended that <span class="emphasis"><em>iscl</em></span> be set to a non-zero value, or that an external scaling function such as <a class="link" href="balance.html" title="balance"><em class="citetitle">balance</em></a> is used. </p> <p> <span class="emphasis"><em>svfilter</em></span> is based upon an algorithm in Hal Chamberlin's <span class="emphasis"><em>Musical Applications of Microprocessor</em></span>s (Hayden Books, 1985). </p> </div> <div class="refsect1" title="Examples"> <a id="idp46867456"></a> <h2>Examples</h2> <p> Here is an example of the svfilter opcode. It uses the file <a class="ulink" href="examples/svfilter.csd" target="_top"><em class="citetitle">svfilter.csd</em></a>. </p> <div class="example"> <a id="idp46868448"></a> <p class="title"> <strong>Example 840. Example of the svfilter 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 svfilter.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; Orchestra file for resonant filter sweep of a sawtooth-like waveform. </span> <span class="comment">; The seperate outputs of the filter are scaled by values from the score,</span> <span class="comment">; and are mixed together.</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 2205 <span class="ohdr">ksmps</span> <span class="op">=</span> 20 <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 idur <span class="op">=</span> p3 ifreq <span class="op">=</span> p4 iamp <span class="op">=</span> p5 ilowamp <span class="op">=</span> p6 <span class="comment">; determines amount of lowpass output in signal</span> ihighamp <span class="op">=</span> p7 <span class="comment">; determines amount of highpass output in signal</span> ibandamp <span class="op">=</span> p8 <span class="comment">; determines amount of bandpass output in signal</span> iq <span class="op">=</span> p9 <span class="comment">; value of q</span> iharms <span class="op">=</span> (<span class="ohdr">sr</span><span class="op">*</span>.4) <span class="op">/</span> ifreq asig <span class="opc">gbuzz</span> 1, ifreq, iharms, 1, .9, 1 <span class="comment">; Sawtooth-like waveform</span> kfreq <span class="opc">linseg</span> 1, idur <span class="op">*</span> 0.5, 4000, idur <span class="op">*</span> 0.5, 1 <span class="comment">; Envelope to control filter cutoff</span> alow, ahigh, aband <span class="opc">svfilter</span> asig, kfreq, iq aout1 <span class="op">=</span> alow <span class="op">*</span> ilowamp aout2 <span class="op">=</span> ahigh <span class="op">*</span> ihighamp aout3 <span class="op">=</span> aband <span class="op">*</span> ibandamp asum <span class="op">=</span> aout1 <span class="op">+</span> aout2 <span class="op">+</span> aout3 kenv <span class="opc">linseg</span> 0, .1, iamp, idur <span class="op">-</span>.2, iamp, .1, 0 <span class="comment">; Simple amplitude envelope</span> <span class="opc">out</span> asum <span class="op">*</span> kenv <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span>1 0 8192 9 1 1 .25 <span class="stamnt">i</span>1 0 5 100 1000 1 0 0 5 <span class="comment">; lowpass sweep</span> <span class="stamnt">i</span>1 5 5 200 1000 1 0 0 30 <span class="comment">; lowpass sweep, octave higher, higher q</span> <span class="stamnt">i</span>1 10 5 100 1000 0 1 0 5 <span class="comment">; highpass sweep</span> <span class="stamnt">i</span>1 15 5 200 1000 0 1 0 30 <span class="comment">; highpass sweep, octave higher, higher q</span> <span class="stamnt">i</span>1 20 5 100 1000 0 0 1 5 <span class="comment">; bandpass sweep</span> <span class="stamnt">i</span>1 25 5 200 1000 0 0 1 30 <span class="comment">; bandpass sweep, octave higher, higher q</span> <span class="stamnt">i</span>1 30 5 200 2000 .4 .6 0 <span class="comment">; notch sweep - notch formed by combining highpass and lowpass outputs</span> <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="idp46870760"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Sean Costello</td> </tr> <tr> <td>Seattle, Washington</td> </tr> <tr> <td>1999</td> </tr> </table> <p> </p> <p>New in Csound version 3.55</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="sumtab.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="syncgrain.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">sumtab </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> syncgrain</td> </tr> </table> </div> </body> </html>