| 1 | |
| 2 | <refentry id="rbjeq"> |
| 3 | <indexterm id="IndexRbjeq"><primary>rbjeq</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Specialized Filters</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>rbjeq</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>rbjeq</refname> |
| 13 | <refpurpose> |
| 14 | Parametric equalizer and filter opcode with 7 filter types, based |
| 15 | on algorithm by Robert Bristow-Johnson. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Parametric equalizer and filter opcode with 7 filter types, |
| 23 | based on algorithm by Robert Bristow-Johnson. |
| 24 | </para> |
| 25 | |
| 26 | |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Syntax</title> |
| 31 | <synopsis>ar <command>rbjeq</command> asig, kfco, klvl, kQ, kS[, imode]</synopsis> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Initialization</title> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>imode (</emphasis> |
| 39 | optional, defaults to zero) - sum of: |
| 40 | |
| 41 | <itemizedlist> |
| 42 | <listitem> |
| 43 | <para> |
| 44 | 1: skip initialization (should be used in tied, or |
| 45 | re-initialized notes only) |
| 46 | </para> |
| 47 | </listitem> |
| 48 | </itemizedlist> |
| 49 | |
| 50 | and exactly one of the following values to select filter type: |
| 51 | |
| 52 | <itemizedlist> |
| 53 | <listitem> |
| 54 | <para> |
| 55 | 0: resonant lowpass filter. kQ controls the resonance: at the |
| 56 | cutoff frequency (kfco), the amplitude gain is kQ (e.g. 20 dB for |
| 57 | kQ = 10), and higher kQ values result in a narrower resonance |
| 58 | peak. If kQ is set to sqrt(0.5) (about 0.7071), there is no |
| 59 | resonance, and the filter has a response that is very similar to |
| 60 | that of butterlp. If kQ is less than sqrt(0.5), there is no |
| 61 | resonance, and the filter has a -6 dB / octave response from about |
| 62 | kfco * kQ to kfco. Above kfco, there is always a -12 dB / octave |
| 63 | cutoff. |
| 64 | |
| 65 | |
| 66 | <note><title>NOTE</title> |
| 67 | <para> |
| 68 | The rbjeq lowpass filter is basically the same as |
| 69 | ar pareq asig, kfco, 0, kQ, 2 but is faster to |
| 70 | calculate. |
| 71 | </para> |
| 72 | </note> |
| 73 | |
| 74 | |
| 75 | </para> |
| 76 | </listitem> |
| 77 | |
| 78 | <listitem> |
| 79 | <para> |
| 80 | 2: resonant highpass filter. The parameters are the |
| 81 | same as for the lowpass filter, but the equivalent |
| 82 | filter is butterhp if kQ is 0.7071, and "ar pareq |
| 83 | asig, kfco, 0, kQ, 1" in other cases. |
| 84 | </para> |
| 85 | </listitem> |
| 86 | |
| 87 | <listitem> |
| 88 | <para> |
| 89 | 4: bandpass filter. kQ controls the bandwidth, which |
| 90 | is kfco / kQ, and must be always less than sr / 2. The |
| 91 | bandwidth is measured between -3 dB points (i.e. |
| 92 | amplitude gain = 0.7071), beyond which there is a +/- |
| 93 | 6 dB / octave slope. This filter type is very similar |
| 94 | to ar butterbp asig, kfco, kfco / kQ. |
| 95 | </para> |
| 96 | </listitem> |
| 97 | |
| 98 | <listitem> |
| 99 | <para> |
| 100 | 6: band-reject filter, with the same parameters as the |
| 101 | bandpass filter, and a response similar to that of |
| 102 | butterbr. |
| 103 | </para> |
| 104 | </listitem> |
| 105 | |
| 106 | <listitem> |
| 107 | <para> |
| 108 | 8: peaking EQ. It has an amplitude gain of 1 (0 dB) at |
| 109 | 0 Hz and sr / 2, and klvl at the center frequency |
| 110 | (kfco). Thus, klvl controls the amount of boost (if it |
| 111 | is greater than 1), or cut (if it is less than 1). |
| 112 | Setting klvl to 1 results in a flat response. |
| 113 | Similarly to the bandpass and band-reject filters, the |
| 114 | bandwidth is determined by kfco / kQ (which must be |
| 115 | less than sr / 2 again); however, this time it is |
| 116 | between sqrt(klvl) points (or, in other words, half |
| 117 | the boost or cut in decibels). NOTE: excessively low |
| 118 | or high values of klvl should be avoided (especially |
| 119 | with 32-bit floats), though the opcode was tested with |
| 120 | klvl = 0.01 and klvl = 100. klvl = 0 is always an |
| 121 | error, unlike in the case of pareq, which does allow a |
| 122 | zero level. |
| 123 | </para> |
| 124 | </listitem> |
| 125 | |
| 126 | <listitem> |
| 127 | <para> |
| 128 | 10: low shelf EQ, controlled by klvl and kS (kQ is |
| 129 | ignored by this filter type). There is an amplitude |
| 130 | gain of klvl at zero frequency, while the level of |
| 131 | high frequencies (around sr / 2) is not changed. At |
| 132 | the corner frequency (kfco), the gain is sqrt(klvl) |
| 133 | (half the boost or cut in decibels). The kS parameter |
| 134 | controls the steepness of the slope of the frequency |
| 135 | response (see below). |
| 136 | </para> |
| 137 | </listitem> |
| 138 | |
| 139 | <listitem> |
| 140 | <para> |
| 141 | 12: high shelf EQ. Very similar to the low shelf EQ, |
| 142 | but affects the high frequency range. |
| 143 | </para> |
| 144 | </listitem> |
| 145 | |
| 146 | </itemizedlist> |
| 147 | |
| 148 | |
| 149 | The default value for imode is zero (lowpass filter, |
| 150 | initialization not skipped). |
| 151 | |
| 152 | </para> |
| 153 | |
| 154 | </refsect1> |
| 155 | |
| 156 | <refsect1> |
| 157 | <title>Performance</title> |
| 158 | |
| 159 | <para> |
| 160 | <emphasis>ar</emphasis> |
| 161 | -- the output signal. |
| 162 | </para> |
| 163 | |
| 164 | <para> |
| 165 | <emphasis>asig</emphasis> |
| 166 | -- the input signal |
| 167 | |
| 168 | <note> |
| 169 | <title>NOTE</title> |
| 170 | |
| 171 | <para> |
| 172 | If the input contains silent sections, on Intel CPUs a |
| 173 | significant slowdown can occur due to denormals. In such |
| 174 | cases, it is recommended to process the input signal with |
| 175 | "denorm" opcode before filtering it with rbjeq (and actually |
| 176 | many other filters). |
| 177 | </para> |
| 178 | |
| 179 | </note> |
| 180 | </para> |
| 181 | |
| 182 | <para> |
| 183 | <emphasis>kfco</emphasis> |
| 184 | -- cutoff, corner, or center frequency, depending on filter type, |
| 185 | in Hz. It must be greater than zero, and less than sr / 2 (the |
| 186 | range of about sr * 0.0002 to sr * 0.49 should be safe). |
| 187 | </para> |
| 188 | |
| 189 | <para> |
| 190 | <emphasis>klvl</emphasis> |
| 191 | -- level (amount of boost or cut), as amplitude gain (e.g. 1: flat |
| 192 | response, 4: 12 dB boost, 0.1: 20 dB cut); zero or negative values |
| 193 | are not allowed. It is recognized by the peaking and shelving EQ |
| 194 | types (8, 10, 12) only, and is ignored by other filters. |
| 195 | </para> |
| 196 | |
| 197 | <para> |
| 198 | <emphasis>kQ</emphasis> |
| 199 | -- resonance (also kfco / bandwidth in many filter types). Not |
| 200 | used by the shelving EQs (imode = 10 and 12). The exact meaning of |
| 201 | this parameter depends on the filter type (see above), but it |
| 202 | should be always greater than zero, and usually (kfco / kQ) less |
| 203 | than sr / 2. |
| 204 | </para> |
| 205 | |
| 206 | <para> |
| 207 | <emphasis>kS</emphasis> |
| 208 | -- shelf slope parameter for shelving filters. Must be greater |
| 209 | than zero; a higher value means a steeper slope, with resonance if |
| 210 | kS > 1 (however, a too high kS value may make the filter |
| 211 | unstable). If kS is set to exactly 1, the shelf slope is as steep |
| 212 | as possible without a resonance. Note that the effect of kS - |
| 213 | especially if it is greater than 1 - also depends on klvl, and it |
| 214 | does not have any well defined unit. |
| 215 | </para> |
| 216 | |
| 217 | </refsect1> |
| 218 | |
| 219 | <refsect1> |
| 220 | <title>Examples</title> |
| 221 | <para> |
| 222 | Here is an example of the <emphasis>rbjeq</emphasis> opcode. It uses the file <ulink url="examples/rbjeq.csd"><citetitle>rbjeq.csd</citetitle></ulink>. |
| 223 | <example> |
| 224 | <title>An example of the rbjeq opcode.</title> |
| 225 | |
| 226 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 227 | <xi:include href="examples-xml/rbjeq.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 228 | </example> |
| 229 | </para> |
| 230 | </refsect1> |
| 231 | |
| 232 | <refsect1> |
| 233 | <title>See also</title> |
| 234 | <para><link linkend="SigmodSpeciali"><citetitle>Specialized Filters: Parametric EQ</citetitle></link></para> |
| 235 | </refsect1> |
| 236 | |
| 237 | <refsect1> |
| 238 | <title>Credits</title> |
| 239 | <para> |
| 240 | <simplelist> |
| 241 | <member>Original algorithm by Robert Bristow-Johnson</member> |
| 242 | <member> |
| 243 | Csound orchestra version by Josep M Comajuncosas, Aug 1999 |
| 244 | </member> |
| 245 | <member> |
| 246 | Converted to C (with optimizations and bug fixes) by Istvan |
| 247 | Varga, Dec 2002 |
| 248 | </member> |
| 249 | </simplelist> |
| 250 | </para> |
| 251 | </refsect1> |
| 252 | </refentry> |