You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1076 lines
1.0 MiB
1076 lines
1.0 MiB
11 years ago
|
{
|
||
|
"metadata": {
|
||
|
"name": ""
|
||
|
},
|
||
|
"nbformat": 3,
|
||
|
"nbformat_minor": 0,
|
||
|
"worksheets": [
|
||
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"%pylab inline\n",
|
||
|
"from scipy import signal"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"output_type": "stream",
|
||
|
"stream": "stdout",
|
||
|
"text": [
|
||
|
"Populating the interactive namespace from numpy and matplotlib\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 1
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"This notebook contains a detailed description of implementing classic second order filter sections using matrix arithmetic.\n",
|
||
|
"The matrix formulation lends itself to robust, fast evaluation on SIMD architectures. Second order filter sections are\n",
|
||
|
"extremely versatile, as a single section can implement many different types of filter, including lowpass, highpass,\n",
|
||
|
"bandpass, notch, bell, low shelf, and high shelf. Being second order, rolloff is 12dB/octave. For sharper frequency\n",
|
||
|
"response, higher order IIR filters can be decomposed into multiple second order sections.\n",
|
||
|
"\n",
|
||
|
"All second order filters can be described using two state variables. The evolution of the state is a 2x2 matrix. In addition,\n",
|
||
|
"there is a 2-vector describing the contribution of the input to the state, a 2-vector describing \"reading out\" the state to\n",
|
||
|
"the output, and a scalar for the zero-delay contribution of the input to the output. For mathematical convenience, we group\n",
|
||
|
"the last two into a single 3-vector. Thus, a filter is described as the tuple $(\\mathbf{A}, B, C)$, and each step is as follows:\n",
|
||
|
"\n",
|
||
|
"\\begin{align}\n",
|
||
|
" out_n & = C \\cdot concat([[x_n], y_n]) \\\\\n",
|
||
|
" y_{n+1} & = B \\cdot x_n + \\mathbf{A} \\cdot y_n\n",
|
||
|
"\\end{align}\n",
|
||
|
"\n",
|
||
|
"Where the $\\cdot$ notation represents dot product, vector times scalar, or matrix times vector multiplication, respectively.\n",
|
||
|
"\n",
|
||
|
"Question: would it be more convenient to have a single 3x3 matrix?\n",
|
||
|
"\n",
|
||
|
"There is some redundancy in this representation. Obviously, multiplying A and B times some scalar, and dividing C by the same,\n",
|
||
|
"is a filter with the same results. More subtly, the y vector can be transformed by any non-degenerate linear transformation.\n",
|
||
|
"However, these transforms do matter when the filter parameters are modulated, which is especially common in synthesizers, and\n",
|
||
|
"also matter for roundoff behavior (particularly important when evaluating the filters using 32 bit floating point arithmetic).\n",
|
||
|
"\n",
|
||
|
"The reference code for evaluating a filter in this form is straightforward:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def eval(filt, inp):\n",
|
||
|
" A, B, C = filt\n",
|
||
|
" result = []\n",
|
||
|
" y = zeros(2)\n",
|
||
|
" for x in inp:\n",
|
||
|
" result.append(dot(C, concatenate([[x], y])))\n",
|
||
|
" y = B * x + dot(A, y)\n",
|
||
|
" return array(result)"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 2
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Now how do we get a filter in this form? Starting from standard biquad coefficients is, again, pretty easy. Here, the\n",
|
||
|
"y vector represents the two state variables in transposed direct form II. For review, the transfer function of this\n",
|
||
|
"filter is:\n",
|
||
|
"\n",
|
||
|
"\\begin{equation} H(z) = \\frac{b_0 + b_1 z^{-1} + b_2 z^{-2}}{1 + a_1 z^{-1} + a_2 z^{-2}} \\end{equation}"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def from_biquad(coefs):\n",
|
||
|
" b0, b1, b2, a1, a2 = coefs\n",
|
||
|
" A = array([[-a1, 1], [-a2, 0]])\n",
|
||
|
" B = array([b1 - a1 * b0, b2 - a2 * b0])\n",
|
||
|
" C = array([b0, 1, 0])\n",
|
||
|
" return A, B, C"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 3
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We can test this against a straightforward implementation (in this case, direct form I)."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def biquad(coefs, inp):\n",
|
||
|
" b0, b1, b2, a1, a2 = coefs\n",
|
||
|
" out = zeros(len(inp))\n",
|
||
|
" x1 = 0\n",
|
||
|
" x2 = 0\n",
|
||
|
" y1 = 0\n",
|
||
|
" y2 = 0\n",
|
||
|
" for i in range(len(inp)):\n",
|
||
|
" x = inp[i]\n",
|
||
|
" y = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2\n",
|
||
|
" out[i] = y\n",
|
||
|
" x2, x1 = x1, x\n",
|
||
|
" y2, y1 = y1, y\n",
|
||
|
" return out\n",
|
||
|
"\n",
|
||
|
"impulse = zeros(100)\n",
|
||
|
"impulse[10] = 1\n",
|
||
|
"coefs = 1.0207, -1.7719, .9376, -1.7719, 0.9583 # peaking\n",
|
||
|
"plot(biquad(coefs, impulse))\n",
|
||
|
"plot(eval(from_biquad(coefs), impulse))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEACAYAAAC6d6FnAAAABHNCSVQICAgIfAhkiAAAAAlwSFl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GwtVVTFhwgSs\nXr26zpi33noLd911F6KjowEAbdu29eaUTULYdIRoKkKDNFhsAEQkCa8CoKSkBDExMbW3o6OjUVJS\nUmdMQUEBysvLccsttyAtLQ1vvPGGN6dsEkIx0CJEQ7CmQihsAEQkB6+WgBRFuewYwzCwc+dOfPbZ\nZ6iqqsJNN92EG2+8EQkJCXXGzZ49u/b79PT05t0rsBlsAER03cvJyUFOTo7PjudVAERFRaGoqKj2\ndlFRUe1SzzkxMTFo27YtQkJCEBISgiFDhmDPnj2XDIBmZ9cRGqwihA2AiK5jF784zsrK8up4Xi0B\npaWloaCgAIWFhdB1HStXrkRGRkadMbfffjs2bdoE0zRRVVWFrVu3okePHl5N2pcsSwB2D0KDVIQF\na7BsbABEJAevGoDD4cDChQsxYsQImKaJqVOnIjk5GYsWLQIAZGZmIikpCSNHjkTv3r1hs9kwbdq0\n6yoAXLoHMB2w2RSEaCpgYwMgIjkoQgjh90koCvw1jbKTVWj3QluI/65C6fHTiPpHR4hnK/0yFyKi\nq+Htc6f0nwQ+49IBSwUAhAaxARCRPKQPgCq3AeXCAHDoNfsCREQBTvoAqHYbUCwNAKCpdsCyQfeY\nfp4VEVHTYwDoBhShnr/DUlHl4jIQEQU+6QOgyqXXLgEBAEwNlS6+FZSIAp/0AVBtGLBd0AAUS0W1\nmw2AiAKf9AHg0g3YhFZ7W7G0
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109465510>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 4
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "heading",
|
||
|
"level": 2,
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"State Variable Filter design"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"However, biquads are not necessarily your best bet for designing second order filters, for two reasons. First, they don't\n",
|
||
|
"modulate well, because the state space for one set of filter parameters probably doesn't make sense with a different filter.\n",
|
||
|
"Second, roundoff behavior can be bad. We'll analyze that in more detail later.\n",
|
||
|
"\n",
|
||
|
"A much better design paradigm is to discretize the State Variable Filter. Historically, many people used the naive\n",
|
||
|
"discretization, originally popularized by Hal Chamberlin's book, _Musical Applications of Microprocessors_ (see\n",
|
||
|
"<https://ccrma.stanford.edu/~jos/svf/svf.pdf>), but this only works well at low frequencies and becomes\n",
|
||
|
"unstable for frequencies around one sixth the sampling rate, or even worse for higher resonance values. Fortunately,\n",
|
||
|
"Andrew Simper of Cytomic has done a thorough development of discretization using trapezoidal integration. This is equivalent\n",
|
||
|
"to the bilinear transform, which is not exactly trivial because the trapezoidal integration (unlike the naive discretization)\n",
|
||
|
"contains a delay-free loop. But fortunately Simper has done all the work for us:\n",
|
||
|
"\n",
|
||
|
"[Solving the continuous SVF equations using trapezoidal integration and equivalent currents](http://www.cytomic.com/files/dsp/SvfLinearTrapOptimised2.pdf)\n",
|
||
|
"\n",
|
||
|
"For simplicity, we'll start with just a lowpass filter. As we'll see later, the full derivation is very general and can\n",
|
||
|
"do the entire RBJ suite of filter designs."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def svf_lp(f, res):\n",
|
||
|
" g = tan(pi * f)\n",
|
||
|
" k = 2 - 2 * res # 1/Q\n",
|
||
|
" a1 = 1/(1 + g * (g + k))\n",
|
||
|
" a2 = g * a1\n",
|
||
|
" a3 = g * a2\n",
|
||
|
" A = array([[2*a1 - 1, -2*a2],\n",
|
||
|
" [2*a2, 1 - 2*a3]])\n",
|
||
|
" B = array([2 * a2, 2 * a3])\n",
|
||
|
" C = array([a3, a2, 1 - a3])\n",
|
||
|
" return A, B, C"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 5
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Simper prefers a resonance control that ranges from 0 to 1. If you prefer the classic Q, just use this conversion:\n",
|
||
|
"\n",
|
||
|
"\\begin{equation} res = 1 - .5/Q \\end{equation}\n",
|
||
|
"\n",
|
||
|
"Let's test the filter out:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def db(x):\n",
|
||
|
" return 20 * log(x)/log(10)\n",
|
||
|
"def plot_fr(filter):\n",
|
||
|
" impulse = concatenate([[1], zeros(5000)])\n",
|
||
|
" w, h = signal.freqz(eval(filter, impulse))\n",
|
||
|
" semilogx(w, db(abs(h)))\n",
|
||
|
"axis([3e-3, pi, -60, 10])\n",
|
||
|
"for f in [0.00316, 0.01, 0.0316, 0.1, 0.316, 0.49]:\n",
|
||
|
" plot_fr(svf_lp(f, 0.293))\n"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEFCAYAAADzHRw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XdYFFcXB+DfbKN3BBVUEFBE0BhrEgsWVFDRoKJorLFE\nY4waEzWJJVGDJeYzsSRGY4sFYiFYEmILphrsDeyoKIIKio26O98fV7EAC7s7y+yO532efYDdKQdG\nz969c++5HM/zPAghhJg9mdgBEEIIEQYldEIIkQhK6IQQIhGU0AkhRCIooRNCiERQQieEEIkwOKEP\nHToU7u7uCAoKKn4uOzsbISEhqFOnDjp27Ii7d+8aehpCCCHlMDihDxkyBAkJCc89N2fOHISEhODc\nuXNo37495syZY+hpCCGElIMTYmLR5cuX0a1bN5w8eRIA4O/vj/3798Pd3R0ZGRkIDg7GmTNnDA6W\nEEJI2YzSh56ZmQl3d3cAgLu7OzIzM41xGkIIIc8w+k1RjuPAcZyxT0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/7D5Ohp2E\n32I/VImoIuixb9/ehhs3VqBBg+1l505eJCKeWvI0Gp6PieH5qlV5fvx4nn/4UOyIhHXzwU1+yp4p\nvPNcZ/79X9/n7+beFTsk4Wg0PP/bbzzfuDHPt2jB8//8I3ZEgrpXWMh/lprKu/z5Jz8jNZXPLSoS\nOyTB3Tt8j/+ryl/8nT/vCHrcrKxd/LFjHbTmTml8riPP4Tg2kOLkSeDmTSAoCPj9d7GjEk4Vmyr4\nov0XODvmLB4UPEC9JfWw/sR6
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094af490>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 6
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"This is the classic BLT lowpass filter response, with complete attenuation at Nyquist and the characteristic frequency warping."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"axis([3e-3, pi, -60, 10])\n",
|
||
|
"for f in [0.00316, 0.01, 0.0316, 0.1, 0.316, 0.49]:\n",
|
||
|
" plot_fr(svf_lp(f, 0.8))\n"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEFCAYAAADzHRw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXdYVMfXx793G0uvUmSVIihiwRKxJCpqiL0raOwtUaOx\nxRKNkdiwRBMTNeZNbMnPRCxR1ERjJbbYu1gRBUQQpUmH3Xn/GCUWypa7e3fX+TzPPiy3zHzJmrPn\nnjlzDkcIIWAwGAyGySMSWgCDwWAw+IEZdAaDwTATmEFnMBgMM4EZdAaDwTATmEFnMBgMM4EZdAaD\nwTATdD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G6HVOJ0snjA8e\njwXHFuh1HgBAXh6tvxISAgwZQleu9V0dbc4c4JtvDFK0hxCCTampqHP2LOzEYpx/5x00tLXV23xT\nq1XD14mJUBlRAb+EJQlIWZ+CoENBkDpI1b5P6iSF1FWKvFu6LdKrVGrcr9NXhg4IOLXRUVxMyMqV\nND3ZkLs6VSpCBg8mpHdv9TYraktMfAxpuKYhaf5zc3I66bT+JiqDjPwM4rLEhdx5ekc/EyiVhPzy\nC93lFR5OSFKSfuYpj/BwQhYv1usUF7KzSbuLF0n9M2fIKb4WditBpVKRRmfPkl1GsHtUWawkt8fd\nJqcDT2u96/N6v+vk0cZHOun4919ftrHIGFGpCLl+nZAVK+jGPwcHQt59l5DbBowMvKCggJDmzQmZ\nPZv/se8+vUt6RfUi1b+pTn6/+rtgdVYijkSQoTuH8juoUklrq9SrR2svnDjB7/jqcu0aIW5uhOTk\n8D703bw80u/6deJ+4gRZmZRE
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109738650>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 7
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"As promised, the rest of the RBJ designs. Note that in this version, for all types other then the shelf filters, the calculation\n",
|
||
|
"of a1, a2, a3 has been reworked a bit to be done directly in terms of sine and cosine of the frequency, rather than tangent in\n",
|
||
|
"Simper's derivation (but should be mathematically equivalent). This version should be slightly faster to compute and also more\n",
|
||
|
"numerically robust."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def svf_core(f, res, m, shelfA = 1):\n",
|
||
|
" k = 2 - 2 * res\n",
|
||
|
" if shelfA == 1:\n",
|
||
|
" s = sin(2 * pi * f)\n",
|
||
|
" rs = 1 / (2 + k * s)\n",
|
||
|
" rc = rs * cos(2 * pi * f)\n",
|
||
|
" a1 = rs + rc\n",
|
||
|
" a2 = s * rs\n",
|
||
|
" a3 = rs - rc\n",
|
||
|
" else:\n",
|
||
|
" g = tan(pi * f) * shelfA\n",
|
||
|
" a1 = 1/(1 + g * (g + k))\n",
|
||
|
" a2 = g * a1\n",
|
||
|
" a3 = g * a2\n",
|
||
|
" A = array([[2*a1 - 1, -2*a2],\n",
|
||
|
" [2*a2, 1 - 2*a3]])\n",
|
||
|
" B = array([2 * a2, 2 * a3])\n",
|
||
|
" C_v0 = array([1, 0, 0])\n",
|
||
|
" C_v1 = array([a2, a1, -a2])\n",
|
||
|
" C_v2 = array([a3, a2, 1 - a3])\n",
|
||
|
" C = m[0] * C_v0 + m[1] * C_v1 + m[2] * C_v2\n",
|
||
|
" return A, B, C\n",
|
||
|
"\n",
|
||
|
"def svf_lp(f, res):\n",
|
||
|
" return svf_core(f, res, [0, 0, 1])\n",
|
||
|
"\n",
|
||
|
"def svf_bp(f, res):\n",
|
||
|
" return svf_core(f, res, [0, 1, 0])\n",
|
||
|
"\n",
|
||
|
"def svf_hp(f, res):\n",
|
||
|
" k = 2 - 2 * res\n",
|
||
|
" return svf_core(f, res, [1, -k, -1])\n",
|
||
|
"\n",
|
||
|
"def svf_notch(f, res):\n",
|
||
|
" k = 2 - 2 * res\n",
|
||
|
" return svf_core(f, res, [1, -k, 0])\n",
|
||
|
"\n",
|
||
|
"def svf_peak(f, res):\n",
|
||
|
" k = 2 - 2 * res\n",
|
||
|
" return svf_core(f, res, [1, -k, -2])\n",
|
||
|
"\n",
|
||
|
"def svf_bell(f, Q, gaindB):\n",
|
||
|
" A = 10 ** (gaindB / 40.)\n",
|
||
|
" k = 1/(Q * A)\n",
|
||
|
" return svf_core(f, 1 - 0.5 * k, [1, k * (A * A - 1), 0])\n",
|
||
|
"\n",
|
||
|
"def svf_lowshelf(f, Q, gaindB):\n",
|
||
|
" A = 10 ** (gaindB / 40.)\n",
|
||
|
" k = 1./Q\n",
|
||
|
" return svf_core(f, 1 - 0.5 * k, [1, k * (A - 1), A * A - 1], 1/sqrt(A))\n",
|
||
|
"\n",
|
||
|
"def svf_highshelf(f, Q, gaindB):\n",
|
||
|
" A = 10 ** (gaindB / 40.)\n",
|
||
|
" A2 = A * A\n",
|
||
|
" k = 1./Q\n",
|
||
|
" return svf_core(f, 1 - 0.5 * k, [A2, k * (A - A2), 1 - A2], sqrt(A))"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 8
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"axis([3e-3, pi, -60, 10])\n",
|
||
|
"f0 = 0.013\n",
|
||
|
"res = 0.293\n",
|
||
|
"plot_fr(svf_lp(f0, res))\n",
|
||
|
"plot_fr(svf_bp(f0, res))\n",
|
||
|
"plot_fr(svf_hp(f0, res))\n",
|
||
|
"plot_fr(svf_notch(f0, res))\n",
|
||
|
"plot_fr(svf_peak(f0, res))\n"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEFCAYAAADzHRw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4FFXbwOHfZrOp1FACJEKAhBRBQBQkikZ6EUQUBCwI\n+IIUURCFFz4VVAyiiAovAlKkiKCixgIRlCJKB6mhNyGhphBI393z/TEQAoSQsruTbJ77uuaa3dnZ\nmSeZ5NmzZ04xKKUUQgghSjwXvQMQQghhG5LQhRDCSUhCF0IIJyEJXQghnIQkdCGEcBKS0IUQwkkU\nOaH369cPX19fGjRokL0tISGBNm3aUK9ePdq2bUtSUlJRTyOEEOIOipzQ+/btS3R09A3bJk6cSJs2\nbTh06BCtWrVi4sSJRT2NEEKIOzDYomPRiRMn6Ny5M3v27AEgJCSEdevW4ev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DzExcOCAlnRr\n1wZ//+vLtU8rX9/rSdzd3W6hpVosHEtL42RGBnEZGcRlZt6yvpCZiZfRiI+rK5VMJnxMJnxcXW9Y\nlzUaKXPT4n3TczeDoUR9Ky/pdGm2uGLFiuxmi/379+e///1vvoMStpdqsXAuM5OzOZJ8dsK/uv1M\nZiaxGRkEeHgQ6u1NmJcXYd7ehHp5EeLlhZfRcc3kLl68niP374e9e2HrVi0ntmihLQ89BFfvuzvG\n6dOwdi1s2KAtR45A48Zw333aJ05oqLY46FPHqhQn09PZnZLC3pQUjqSlcfTqEp+VRYCHBwEeHvi5\nu1PD3Z0abm7Z6+publR1c8PN
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1097dcbd0>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 9
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"axis([3e-3, pi, -40, 40])\n",
|
||
|
"for gain in range(-30, 31, 10):\n",
|
||
|
" plot_fr(svf_bell(f0, .5, gain))"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEFCAYAAADzHRw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XdYVMfeB/AvvfeyVMVCEY2AKNYoiDUGxJhojD3GxGiK\nvknEe280Jl4VW2wxibHGaKJ4ExHssWCJir2BgihKXeqylF3Y9nv/GMUYI0H3LM35PM95ljozwPLd\nOXNm5ugREYHjOI5r8vQbugEcx3GcMHigcxzHNRM80DmO45oJHugcx3HNBA90juO4ZoIHOsdxXDMh\nSKCr1WoEBQUhIiICAFBSUoL+/fvDx8cHAwYMQGlpqRDVcBzHcbUQJNBXrlwJf39/6OnpAQBiYmLQ\nv39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09/7OOf\nffYZxcTEEBHRwoULKTo6+onv1bJqrhk5e/Ysubi40Nq1awUpT6kspbS0j+jUKSfKzv6WlMqyWr9e\npaqg3NyNdPasD127NpTk8vuCtGP9+vXk6upKFy5cEKQ8jiOqPTu1StWTJ0+Snp4eBQQEUGBgIAUG\nBtL+/fupuLiYwsPDydvbm/r3708SieSZGsW9OHbv3k2Ojo6UkJCgdVkajYby8n6iP/5wpVu33qHq\n6sJn+n61uooyMr6ikycdKDNzGWk0aq3btGvXLnJycqJDhw5pXRbHEdWenXzpP9dgvvvuO8ybNw+7\nd+9Gly5dtCpLpSpHauo7kMluwsfnB9jYPP9yfJnsNm7dmggDA0u0a7cFxsbaTUM8ceIERowYgdmz\nZ2PatGlalcVx/AYXXKOiVqvx
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109450510>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 10
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"axis([3e-3, pi, -40, 40])\n",
|
||
|
"for gain in range(-30, 31, 10):\n",
|
||
|
" plot_fr(svf_lowshelf(f0, .707, gain))\n",
|
||
|
" plot_fr(svf_highshelf(f0, .707, gain))"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEFCAYAAADzHRw3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd8FGX+wPHPtuxuet80IAmQ0LtBLAjnAVJEbNwpKiqc\neOpZzoJdPE/BfvaC/hTLKWBBBBRQTgXpHUJJIISENNI3yZbs7jy/PwZCIknYNBLged9rbmZn5pnn\n2ez65dlnnnkejRBCIEmSJJ3xtO1dAEmSJKl1yIAuSZJ0lpABXZIk6S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NOmTZx33nlcdtllfPXVV/j7\nn7m/MqQzk2xykTqk4uIf2LdvKl27vkJU1A3tXZxTWrhwIXfeeSfvv/8+kyZNau/iSGcx2YYunZGq\nqlLZtetyIiOvIyHhGTSajveDUgjBCy+8wJtvvsn333/PgAED2rtI0lmuzdrQs7OzGTlyJL1796ZP\nnz68/vrrAJSUlDBq1CiSkpIYPXo0ZWVlLclGOkf5+fVm0KANlJX9SmrqZDweW3sXqQ6Xy8WMGTP4\n4osvWLdunQzmUrtrUQ09Pz+f/Px8BgwYQGVlJYMHD2bRokV89NFHhIeH89BDD/H8889TWlrKnDlz\n6mYsa+iSlxTFyf7907HbD9K37/cYDGHtXSTKy8uZPHkyOp2O+fPnExAQ0N5Fks4RbVZDj4qKqqmV\n+Pv707NnT3Jycli8eDFTp04FYOrUqSxatKgl2UjnOK3WSI8e8wgKuoht2y7G4chu1/Lk5eUxfPhw\nunbtyuLFi2UwlzqMVmuUzMzM
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1097aa810>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 11
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "heading",
|
||
|
"level": 2,
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Fast matrix evaluation"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The matrix form above is reasonably efficient to implement. However, to maximally take advantage of the power of modern\n",
|
||
|
"SIMD, we can construct a single 4x4 matrix that computes _two_ samples in a single iteration. Thus, the iteration of the\n",
|
||
|
"state is represented by the square of the $\\mathbf{A}$ matrix above."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def mk4mat(filter):\n",
|
||
|
" A, B, C = filter\n",
|
||
|
" AA = dot(A, A)\n",
|
||
|
" AB = dot(A, B)\n",
|
||
|
" CA = dot(C[1:], A)\n",
|
||
|
" cb = dot(C[1:], B)\n",
|
||
|
" return array([[C[0], 0, C[1], C[2]],\n",
|
||
|
" [cb, C[0], CA[0], CA[1]],\n",
|
||
|
" [AB[0], B[0], AA[0][0], AA[0][1]],\n",
|
||
|
" [AB[1], B[1], AA[1][0], AA[1][1]]])"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 12
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Then, evaluation is again quite simple, each iteration processing two samples. The central 4x4 matrix-vector multiply is especially\n",
|
||
|
"well suited for implementation in NEON, see cpp/src/neon_iir.s for NEON assembly language."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def eval4(A, inp):\n",
|
||
|
" out = zeros(len(inp))\n",
|
||
|
" y = zeros(4)\n",
|
||
|
" for i in range(0, len(inp), 2):\n",
|
||
|
" y[0:2] = inp[i:i+2]\n",
|
||
|
" y = dot(A, y)\n",
|
||
|
" out[i:i+2] = y[0:2]\n",
|
||
|
" return out"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 13
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Let's test it works the same:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"filter = svf_bp(f0, res)\n",
|
||
|
"plot(eval(filter, impulse))\n",
|
||
|
"plot(eval4(mk4mat(filter), impulse))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "i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9dYjAQ\nUe/GYHCQWTJggF/HwTB74nicVzMYiKh3YzA4yAw9gv07DoYbYodDUlhQVFbXQ1UREbkeg8FBFsGA\n0MCO5xgUCgEhpvH4z2FOQBNR78VgcJCoMCAkoOMRAwBoA8fhACegiagXYzA4SFQaEBrUeTBMihyP\nUh2DgYh6LwaDg2wqPQYN6DwYZk8Yj3OcgCaiXozB4ACbTQLUBoeC4aaESEjKZhz735keqIyIyPUY\nDA5oNLYANhX8fNSdtlUoBAQ3j8N7BZyAJqLeicHggHM6AwRr56OFK7QB47G/nKeTiKh3YjA44Owl\nPRRdCIZJkeNRcpHBQES9E4PBAReaDFCKHV/D8H2zksfjnIrBQES9E4PBARebDFBJjo8YUq8bCVHV\nhBNVZ91YFRGRezAYHHDRYIC6C8GgUAgY2Dwe7x484saqiIjcg8HggAa9Hl6C48EAADGBKdh36rCb\nKiIich8GgwMuNRvgLTg+xwAAk6MnouRSoZsqIiJyHwaDAxqbDfBRdG3EcNdNKbjgXcjvgCaiXofB\n4ICmFgN8VV0LhqSooVCI/vj4aIWbqiIicg8GgwOaWvRdDgYAGCJOxPbDnGcgot6FweAAg9mAAK+u\nzTEAQOI1KTj4NecZiKh3YTA4wGgxIMCr6yOGafETUW7iiIGIehcGgwOaRQMCvLseDHfdPB4Gv+PQ\nN5vdUBURkXswGBzQLOoR5NONOYaQAPg0R2H7p0fdUBURkXswGBzQYjMg2K/rcwwAcK0yBbuOcp6B\niHoPBoMDWiQDBvh1fcQAABPD
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109489d90>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 14
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"With the 4x4 matrix formulation, each iteration performs 16 multiplies and 12 adds to compute two samples, or 8 multiplies and\n",
|
||
|
"6 adds per sample. This is slightly better than the 9 multiplies and 8 adds for the most general form of Simper's code,\n",
|
||
|
"and roughly the same as most of the specialized forms. However, raw number of multiply/add operations tells only a small part\n",
|
||
|
"of the speed story. All these operations are grouped for easy computation in 4x wide SIMD instructions. On NEON, this yields\n",
|
||
|
"1.47ns per IIR on a Nexus 5, which is 6x a straightforward scalar implementation of direct form I biquad evaluation."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "heading",
|
||
|
"level": 2,
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Error measurement"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We want to evaluate these filters in floating point arithmetic for speed. IIR filters are notoriously finicky about\n",
|
||
|
"roundoff error.\n",
|
||
|
"\n",
|
||
|
"For these tests, we'll run a filter in double math, then the same filter in float, and compare."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def eval4_f32(A, inp):\n",
|
||
|
" A = array(A, dtype=float32)\n",
|
||
|
" inp = array(inp, dtype=float32)\n",
|
||
|
" out = zeros(len(inp), dtype=float32)\n",
|
||
|
" y = zeros(4, dtype=float32)\n",
|
||
|
" for i in range(0, len(inp), 2):\n",
|
||
|
" y[0:2] = inp[i:i+2]\n",
|
||
|
" y = dot(A, y)\n",
|
||
|
" out[i:i+2] = y[0:2]\n",
|
||
|
" return out"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 15
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"impulse = concatenate([[1], zeros(99)])\n",
|
||
|
"filter = mk4mat(svf_lp(.1, .75))\n",
|
||
|
"plot(eval4(filter, impulse) - eval4_f32(filter, impulse))\n",
|
||
|
"grid(True)\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEGCAYAAABxfL6kAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl0VFWeB/BvhQQQWcIiYUkkyJZVKjTLNC1SdLrAAInN\n4ii2OAHHnh6OqHSP3W0zDj3OQKAdFFCPbbsAag8wOtI42KRFTIHKJoQCWQSMRLIQQCDR7NubP66V\nW9krVfe9eqn6fs7JgVf13ru3foFfbn7vvvssmqZpICKigBHi7w4QEZFaTOxERAGGiZ2IKMAwsRMR\nBRgmdiKiAMPETkQUYHRP7IsXL0ZERAQSExOVnO/RRx9FfHw84uLi8Nhjjyk5JxFRINE9sS9atAiZ\nmZlKzuVwOJCdnY2TJ0/i5MmT+Oyzz7B3714l5yYiChS6J/YpU6agb9++jV7LyclBSkoKxo8fjzvv\nvBNnz5716FwRERGorq5GVVUVKioqUFNTg0GDBunRbSKiTivUH43+/Oc/x8svv4yRI0fi0KFDWLJk\nCfbs2dPucbGxsZg+fToGDx4MTdOwdOlSjBkzxoAeExF1HoYn9tLSUhw4cAD33HNPw2vV1dUAgHff\nfRcrVqxodkxkZCR27dqFffv2ISsrCwUFBdA0DXa7HTNmzMAdd9xhWP+JiMzO8MReX1+P8PBwHDt2\nrNl7c+fOxdy5c1s99uDBg0hJSUGPHj0AACkpKThw4AATOxGRG59q7JWVlZg0aRKsVivi4uLw5JNP\ntntM7969MXz4cLzzzjsAAE3TcOLECY/ai4mJwd69e1FXV4eamhrs3bsXcXFxvnwEIqKA41Ni7969\nO7KysuB0OnHixAlkZWXhk08+abTPggULMHnyZJw9exZRUVHYuHEj/vznP+O1116D1WpFQkIC3nvv\nPY/aS0tLQ0JCAsaOHQur1Qqr1YpZs2b58hGIiAKORdWyveXl5Zg6dSo2b97MUTQRkR/5PN2xvr4e\nVqsVERERmDZtGpM6EZGf+ZzYQ0JC4H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SpcDevfq3byYtxSJYMRYSY6GGzzX2LVu2dPgYMyb2d9/Vrx9teekl4I9/FAl+6lT/9IGI\nAktAz4ox24jddcHEJTsbWLECeOON4BuxN41FMGMsJMZCjYCusXua2AcPFhdar17Vry9NlZQAf//3\nwIsvigXKLl4EvvnGuPaJKHAxsUOs7BgXB5w5o19fgMb1w4cfBmbMEMk9NBSYPBn4+GN92zcT1lIl\nxkJiLNTwa2IPDdUvsX/3HVBcDAwd6tn+Rs6MycsT68GvXStfmzo1+MoxRKSPgB2xnz8PjBoFhHj4\nCY2os7vqh1lZgM0mYuASbImdtVSJsZAYCzUMT+yaZszFU0/LMC7GLt8rEru78ePFg73FXbJERN4z\nPLHX1oqadmho8CV2V/0wK6v5Xa5hYeJpTp98om8fzIK1VImxkBgLNQxP7K4yDCCSWW2tPu2cPdux\nxB4ZCZSVAdev69Mfl9xcoKICiI1t/l6wlWOISB9+T+xmGbFbLIDVCuzZo09/AFE/dNXXW3rGajAl\ndtZSJcZCYizUCMjErmkdT+wA8NRTwG9+I0bUemmpDOMycSLwxRdi0TIiIm8ZntirqvRP7FeuiBp+\n//4dO85uF6N292mIKmVlORpG7C3p1k1cRP30U33aNxPWUiXGQmIs1PDLiL1bN/F3vRJ7YaHn89eb\nevZZYN06cSeoaoWF4lGAbf0mMXWqmDVDROStgCzFlJUBPXt6d2x0NPDII8C//IvSLgEAKipsmDat\n5fq6y9y5wOuvA//+72KZg0DFWqrEWEiMhRoBmdjLy4Gbb/b++F//Gjh8WNTDVWqrvu5y++3AsWPA\nZ5+JssyRI2r7QESBLyATe1mZ
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109b1fd50>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 16
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"For comparison, here's a similar test with biquad:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"# Adapted directly from Audio EQ Cookbook, by Robert Bristow-Johnson\n",
|
||
|
"def rbj_lpf(f, res):\n",
|
||
|
" w0 = 2 * pi * f\n",
|
||
|
" Q = 1/(2 - 2 * res)\n",
|
||
|
" cw0 = cos(w0)\n",
|
||
|
" b1 = 1 - cw0\n",
|
||
|
" b0 = .5 * b1\n",
|
||
|
" b2 = b0\n",
|
||
|
" alpha = sin(w0)/(2*Q)\n",
|
||
|
" a0 = 1 + alpha\n",
|
||
|
" a1 = -2 * cw0\n",
|
||
|
" a2 = 1 - alpha\n",
|
||
|
" ra0 = 1/a0\n",
|
||
|
" return b0 * ra0, b1 * ra0, b2 * ra0, a1 * ra0, a2 * ra0\n",
|
||
|
"\n",
|
||
|
"def biquad_f32(coefs, inp):\n",
|
||
|
" b0, b1, b2, a1, a2 = map(float32, coefs)\n",
|
||
|
" out = zeros(len(inp), dtype = float32)\n",
|
||
|
" x1 = float32(0)\n",
|
||
|
" x2 = float32(0)\n",
|
||
|
" y1 = float32(0)\n",
|
||
|
" y2 = float32(0)\n",
|
||
|
" for i in range(len(inp)):\n",
|
||
|
" x = float32(inp[i])\n",
|
||
|
" y = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2\n",
|
||
|
" out[i] = y\n",
|
||
|
" x2, x1 = x1, x\n",
|
||
|
" y2, y1 = y1, y\n",
|
||
|
" return out"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 17
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"We'll design the same filter in both biquad and SVF forms, then check that the impulse response is the same."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"coefs = rbj_lpf(.1, .75)\n",
|
||
|
"plot(biquad(coefs, impulse))\n",
|
||
|
"filter = mk4mat(svf_lp(.1, .75))\n",
|
||
|
"plot(eval4(filter, impulse))\n",
|
||
|
"grid(True)\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEACAYAAAC6d6FnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt8FNXdP/DPbHZzzyabOySBQBJy4RY0SNWKWIoxVCIq\nldjnsaDUUq2tWlvQ2seiVUPaWtRi/eXRSmn1AWprgZfKqhSjVo1oMYJyC5Al90BuJCGX3ezO7w+a\nHEIuJDvD7jD7eb9evF47u2dnTj7AfnPO2ZmRZFmWQUREPsfg7Q4QEZF3sAAQEfkoFgAiIh/FAkBE\n5KNYAIiIfBQLABGRj1JcAKxWKzIyMpCWloaioqJBr5eUlCA8PByzZs3CrFmz8Pjjjys9JBERqcCo\n5M1OpxP33HMPdu7ciYSEBMyePRv5+fnIzMwc0O7qq6/G9u3bFXWUiIjUpWgEsHv3bqSmpiI5ORkm\nkwkFBQXYtm3boHY814yISHsUFYCamhokJSX1bycmJqKmpmZAG0mS8NFHH2HmzJlYuHAh9u/fr+SQ\nRESkEkVTQJIknbfNJZdcgqqqKgQHB2PHjh1YvHgxDh8+rOSwRESkAkUFICEhAVVVVf3bVVVVSExM\nHNAmLCys/3FeXh7uvvtuNDc3IzIyctC+amtrlXSHiMinpKSk4MiRI+7vQFbA4XDIkydPlisqKuSe\nnh555syZ8v79+we0qa+vl10ulyzLsvzJJ5/IEydOHHJfCruiG7/85S+93QXNYBYCsxCYhaD0c1PR\nCMBoNGL9+vXIzc2F0+nEihUrkJmZieLiYgDAypUr8be//Q3PP/88jEYjgoODsXnzZiWH1D2bzebt\nLmgGsxCYhcAs1KOoAABnpnXy8vIGPLdy5cr+xz/84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IScuajbvn37cOONN+LIkSODOyJJkGUZHV12hBWGwLnG\nPuhaQACwasNreHnvy6hd95q73SYi0oW+z013KRoB7N69G6mpqUhOTobJZEJBQQG2bds2oE3fhz8A\ndHR0IHqYuf0+x+qah7wQXJ/4CAs6Zf0uAhMReYqiAlBTU4OkpKT+7cTERNTU1Axqt3XrVmRmZiIv\nLw/PPvvsiPs8WtcIk2Po+X8ASIi0oEfS7xQQ5zcFZiEwC4FZqMeo5M2SNPRv6edavHgxFi9ejA8+\n+AC33XYbDh06NGS75cuXo74bgK0DTz/9NLKzs/u/8tX3l54YMwkOY0v/9rmvX+zbfbTSH29ul5WV\naao/3twuKyvTVH+47Z3tvsc2mw1qULQGUFpaijVr1sBqtQIACgsLYTAYsHr16mHfk5KSgt27dyMq\nauBv+X1zWT976e94Zd8rw87xV59sQ9LTCZCfaHe320REuuDVNYCcnByUl5fDZrPBbrdjy5YtyM/P\nH9Dm6NGj/R3cs2cPAAz68D9bXVsTwk3DrxOMjwoD/LrR2e1Q0nUiIp+nqAAYjUasX78eubm5yMrK\nwtKlS5GZmYni4mIUFxcDAP7+979j+vTpmDVrFu69915s3rx5xH2eaG9ERMDwBcJgkCDZI1BRr891\ngLOHer6OWQjMQmAW6lG0BgAAeXl5yMvLG/DcypUr+x+vWrUKq1atGvX+mruaEB82bsQ2RocFlSdb\nMDU5dmydJSKifpo7E7jV3oTY0OFHAMCZS0LX6PSS0H2LPsQszsYsBGahHs0VgE5nG6JCzCO2CUKk\nri8JTUTkCZorAD1yO6LCRi4AIQYL6k/p82Qwzm8KzEJgFgKzUI/2CoDUhuiwsBHbhBktONnOEQAR\nkRKaKwAOqR2xESOPAMIDLGju0mcB4PymwCwEZiEwC/VorgA4/doRFz7yCMASZEGrji8JTUTkCdor\nAKY2xEeOXABiQiN1e0lozm8K
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x10949fa10>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 18
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"And we can see that the error is much less with the matrix state variable approach."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"plot(biquad(coefs, impulse) - biquad_f32(coefs, impulse))\n",
|
||
|
"plot(eval4(filter, impulse) - eval4_f32(filter, impulse))\n",
|
||
|
"grid(True)\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEGCAYAAABsLkJ6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VdW1wPHfzUAIYxIgCSSRBBIyMQRFqSgYxIBMQREF\ntCjKUypFSp+vH2trH1qVobaKilq1Dqh9TCoFESJQCCpTyjwTCAQySwgBwpBxvz+ONychN8kdk3tz\n1/fzyceee849Z2dVz8pe+5y9DUophRBCCLfj0dwNEEII0TwkAQghhJuSBCCEEG5KEoAQQrgpSQBC\nCOGmJAEIIYSbcpoE8MQTTxAUFESfPn1sPtfmzZvp379/9Y+vry+rV6+2QyuFEKLlMDjLewA//PAD\n7dq149FHH+XgwYN2O++FCxeIjIwkJyeH1q1b2+28Qgjh6pymBzB48GD8/f1rfZaRkcHIkSMZMGAA\nQ4YM4fjx4xafd8WKFYwaNUpu/kIIcQOnSQCmPPXUU7z99tvs2rWL1157jRkzZlh8jqVLlzJ58mQH\ntE4IIVybV3M3oD4lJSVs376dBx98sPqzsrIyAL7++mvmzJlT5zuhoaGsW7euejsvL49Dhw4xYsQI\nxzdYCCFcjNMmgKqqKvz8/Ni7d2+dfePHj2f8+PGNnmP58uWMHz8eT09PRzRRCCFcms0lIHOe3pk1\naxZRUVH069fP5A3dlA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L6\nBABQfL3Y5nNZMxV0TSEhjnkSaNcuGDCg9mc3PuPcsSPceSesXWv/6zs7ed5bJ7HQSSzswyUSQNG1\nIpvPZW3938hR7wKYSgCmPPAA
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094a7450>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 19
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The difference is even more dramatic at lower frequencies, where the error of direct form biquad evaluation\n",
|
||
|
"is large."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"impulse = concatenate([[1], zeros(499)])\n",
|
||
|
"coefs = rbj_lpf(0.01, .75)\n",
|
||
|
"filter = mk4mat(svf_lp(0.01, .75))\n",
|
||
|
"plot(biquad(coefs, impulse) - biquad_f32(coefs, impulse))\n",
|
||
|
"plot((eval4(filter, impulse) - eval4_f32(filter, impulse)))\n",
|
||
|
"grid(True)\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEGCAYAAABsLkJ6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4VOXZ+PHvTBa2QBKWBLJAICSEQEgCSIQKBhEQkMhi\nX0BbpWJFcSlqFe2vFXyrIK3Lq0X7IlZQa8GqRaJCXkAcRCBGkSCyBkkkCSFsIRCWrOf3x2MyQhaS\nmXNmvT/Xlas9M5NzHm7h3HPuZzNpmqYhhBDC65id3QAhhBDOIQlACCG8lCQAIYTwUpIAhBDCS0kC\nEEIILyUJQAghvJTLJIC77rqL0NBQEhIS7D7X559/TnJyct1PmzZtSE9P16GVQgj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jRihyiQ33GDM+Z3l0Ueh\nvByWLKn/XnGx6v/Yvl3/4bVCCNu59DyAtLQ03n77bQAyMzMJCgqqd/PX27Fj0LWrcefv108tNeFJ\niotV+efJJxt+PzQUfv97+OMfHdsuIYRx7E4AM2bMYNiwYRw4cIDIyEjefPNNli5dytKlSwEYP348\nvXr1onfv3syePZvXXnvN7kY3pbpaLfxmZI4ZMgS++sq4819Z/nCEF16A22+H8PDGP3P//bBxo+pj\ncRRnxMJVSSysJBb6sLsPYOXKlVf9zJKGagoGOXUKAgPB39+4a1x7Lfz5z8ad39EqK2HFClXeaUr7\n9nDHHfDaa/Dccw5pmhDCQB63FtCuXfCrXxlboqmpgY4dIScHunQx7jqOsm6d2iznagkA1P4KQ4dC\nfj60bm1824QQTXPpPgBHM7r+
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x10949fc50>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 20
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"By visualizing the state of the filter, it's possible to see intuitively where the difference in numerical robustness\n",
|
||
|
"comes from. In the SVF, where the state corresponds to physical quantities, the norm of the state vector is close to\n",
|
||
|
"the system's energy."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def eval_showstate(filt, inp):\n",
|
||
|
" A, B, C = filt\n",
|
||
|
" result = []\n",
|
||
|
" y = zeros(2)\n",
|
||
|
" for x in inp:\n",
|
||
|
" result.append(y)\n",
|
||
|
" y = B * x + dot(A, y)\n",
|
||
|
" return result\n",
|
||
|
"\n",
|
||
|
"impulse = concatenate([[1], zeros(49)])\n",
|
||
|
"filt = svf_lp(0.02, 0.5)\n",
|
||
|
"xs, ys = zip(*eval_showstate(filt, impulse))\n",
|
||
|
"axes().set_aspect(1)\n",
|
||
|
"grid(True)\n",
|
||
|
"plot(xs, ys, '-o')"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "pyout",
|
||
|
"prompt_number": 21,
|
||
|
"text": [
|
||
|
"[<matplotlib.lines.Line2D at 0x1094aa250>]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAADdCAYAAAChd+XWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXtcVVX6/98oJokZZYoplNMBBW9g4ZdsCimDo1JM9e1X\ndFEsbegmWd/pJjpSmuI09U2jGZ35zkjOhZxb6QAiOXmgJpFKqWlsEg1KjkJl4TVEDuv3x5YTBw5y\nOftw9obn/Xrtl6191t77wybWc9bzrGc9fkophSAIgiC0op+vBQiCIAjGRAyEIAiC4BYxEIIgCIJb\nxEAIgiAIbhEDIQiCILhFDIQgCILgFo8NRGFhIREREYSHh7Nq1Sq3fdLT0wkPDycqKordu3cD8Omn\nnzJ58mTncf7557NmzRpP5QiCIAg64edJHoTD4WDs2LFs27aNUaNGMWXKFHJzc4mMjHT2KSgoIDs7\nm4KCAnbu3MkjjzxCaWmpy32ampoYNWoUZWVlhIaGdv+nEQRBEHTDoxlEWVkZYWFhjB49mgEDBpCS\nksKmTZtc+mzevJnU1FQAYmNjqauro7a21qXPtm3bsFgsYhwEQRAMhEcGwm63uwzqISEh2O32DvtU\nV1e79Hnttde48847PZEiCIIg6Iy/Jxf7+fl1ql9rL1bL6xoaGvj73//ebvzioosu4vDhw90XKQiC\n0AexWCzs27fPo3t4NIMYNWoUBw4ccLYPHDhASEjIWftUV1czatQoZ3vLli1cccUVDBs2zO0zDh8+\njFLK8EdqaqrXn5GXV0xiYgbTpi0lMTGDvLziLl8/ePBEQDkPi2VRl+/TG96l6DTeITr1Pfbv3+/J\n8A54OIOIi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VUxlZWWEhYU5C2ikpKSwadMmIiMjnX02b95MamoqALGxsdTV\n1VFbW0tAQABvv/02r776KqDVljj//PM9keMR+/bB3r2JnH9+BkeOyMqk3kpHe1o99hg8+ijs2AH/\n938QEaHlWcyfr62Icpf8KAi9FY9cTHa7ndDQUGc7JCQEu93eYZ/q6moqKysZNmwY99xzD5dffjn3\n3XcfJ0+e9EROtykuhquvhsWL4/jDH6ztrsE/G2bxS5pBp7c1JiXFUVi4DJstk8LCZW1+v35+cNVV\n8Nvfwuefw8yZ8Mwz2lboP/0pVFb2jE69EJ36YhadeuDRDMKvZTWas6BaOXT9/PxobGxk165dZGdn\nM2XKFBYuXEhWVhbPPvtsm+vnzp3rnKUEBQURHR1NfHw88P0vq7vtJ5+0sW4d/OUv8Vx/PdhsTTz1\n1HSX/jabrcP7NeOpHm+3y8vLDaXHXbu8vNwwenbtshEeDjt3xvPRR/DMMzaio+G//iueqVOhocHG\nOecY6/21bhvpffaGtlHfp81mIycnB9CvLKpHy1xLS0vJzMyksLAQgJUrV9KvXz+efPJJZ5/777+f\n+Ph4UlJSAIiIiKC4uBilFFOnTqXyzNexd955h6ysLPLy8lwF6rzMtTnPob7eny++aKS+PpHt2+OI\niNDtEUIvp75e24Tx//5P2/bjrrs0F9SECb5WJgjf4/NlrjExMVRUVFBVVUVDQwMbN24kOTnZpU9y\ncjIbNmwANIMSFBREcHAwI0aMIDQ0lL179wKwbds2xo8f74mcDmnOcygqWk5JSSZVVcsJCNjK/v1u\nSqMJQjsEBEBKCmzbpmVun3eelql95ZWa0Th2TOuXn1+C1bqY+PhMrNbF5OfL/2eCyfA0yl1QUKDG\njBmjLBaLWrFihVJKqbVr16q1a9c6+zz00EPKYrGoSZMmqQ8++MB5vry8XMXExKhJkyapm2++2eur\nmBITvbdKySx7xJtBpxk0KuWq
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094aa090>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 21
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"By contrast, with biquad, the state vector is a fairly extreme transform. Thus, even a relatively small error in the\n",
|
||
|
"state variables can lead to a significant delta in energy, resulting in much larger output errors. The transform\n",
|
||
|
"becomes more extreme as the frequency decreases. Note that this is the biquad in matrix form, which is most similar\n",
|
||
|
"to transposed direct form II. However, error behavior is broadly similar, at least in floating point, for all the\n",
|
||
|
"biquad evaluation schemes."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"filt = from_biquad(rbj_lpf(0.02, 0.5))\n",
|
||
|
"xs, ys = zip(*eval_showstate(filt, impulse))\n",
|
||
|
"axes().set_aspect(1)\n",
|
||
|
"grid(True)\n",
|
||
|
"plot(xs, ys, '-o')"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "pyout",
|
||
|
"prompt_number": 22,
|
||
|
"text": [
|
||
|
"[<matplotlib.lines.Line2D at 0x10974ccd0>]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAATQAAAEACAYAAAA9aookAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXtcVHX+/18DeMtKJXVUBkVHbhoOtBZtu8KUDQNS5K00\ntxJt2zLLbusNJWlLhNzaVay1Wi/0rRCrNclBQMph3J+4bqm1LWZEUDBcthA0Tbn5/v1xZGSYAWHO\nmSvv5+MxDz2Hzzmv9wHOm8/n/fm8P28ZEREYhmE8AC9nG8AwDCMV7NAYhvEY2KExDOMxsENjGMZj\nYIfGMIzHwA6NYRiPQbRDy8vLQ0hICAIDA5Genm61zbJlyxAYGAiVSoXjx4+bzi9evBhyu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PAhfjDH4CvvjLg8cfz0dbmXjUK\nvLyA7duBhx4CZs4E9u4VckUZxpHwkNPFcPd1aq2twAMPCDOfe/YIye8M0xN4yOmBuPs6NR8f4J13\nhMmBuXOB5mZnW8T0JdihdcLZMRF7FzN2xPP5+ADvvQf06wfccYceLS12lzTh7J+fJ+m5YwyNHZqL\n0VUx45gY91qn1q8fsGuXMAN6//1wqFNj+i4cQ3NBOq9Ti4zU4G9/i8KePcBvfuNs63pHUxMwezZw\n3XXCUNSHp6GYLuB1aH2IggIh2L57t7DjrDtx8SJwzz3A8OHA229b7pDLMABPCtgFV42JxMQIQ7h7\n7wVeesn2dWrOeL6BA4GPPhJ2y120CGizY9qqq/783FHPHWNoPABwI+64A1i+3IDVq/Nx6ZJ7rVMb\nNAjIyRH2hHvkEeDvfxfWrjGM
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x10974cd10>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 22
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "heading",
|
||
|
"level": 2,
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Modulation"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The main reason to prefer one state space over another for the same transfer function is performance under modulation,\n",
|
||
|
"that is when the filter parameters don't stay constant. Biquad filters are notoriously bad at this. State variable filters\n",
|
||
|
"perform well under modulation and are highly regarded for these use cases.\n",
|
||
|
"\n",
|
||
|
"Let's test it and see how it does."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def saw(freq, n): return 1-2 * (linspace(0, freq * n, num=n, endpoint=False) % 1)\n",
|
||
|
"def sweep(n, maxf = 0.5):\n",
|
||
|
" out = zeros(n)\n",
|
||
|
" ph = 0\n",
|
||
|
" for i in range(n):\n",
|
||
|
" out[i] = sin(ph)\n",
|
||
|
" f = exp(5 * (float(i) / n - 1)) * pi * 2 * maxf\n",
|
||
|
" ph += f\n",
|
||
|
" return out"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 23
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def eval_mod(freq, res, inp, filtf):\n",
|
||
|
" A, B, C = filt\n",
|
||
|
" result = []\n",
|
||
|
" y = zeros(2)\n",
|
||
|
" for i in range(len(inp)):\n",
|
||
|
" x = inp[i]\n",
|
||
|
" A, B, C = filtf(freq[i], res)\n",
|
||
|
" result.append(dot(C, concatenate([[x], y])))\n",
|
||
|
" y = B * x + dot(A, y)\n",
|
||
|
" return result\n"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 24
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The spectrogram looks good."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"n = 10000\n",
|
||
|
"res = 0.9\n",
|
||
|
"specgram(eval_mod(0.25 + 0.2 * sweep(n, 0.1), res, saw(0.05, n), svf_lp))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvcmrdUt65veLbnW7Oe33fbfJm5k4M0WpsJDBYNkFAmHP\nBBYeSnhQSBOhicBjTyT8D3iQI00EnmiugRB4YAQ1kMGgabmUslN58zZfd7rdrCa6GkT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wgpU4UNees3qPqRyr6kAvWo6xoxHDzNbX7NmK\nB865I+QJv2OTZBEkijCD6Bn3jNQz4EACkiU8Lifpr/7WCy64neWJwsYLa2uzeCEJjAsDYjGPZII1\n+9mIFB8hIPJZTkB+ct5T+9jI1LBgaMvPlZ8lgYYRg6XjQEAhCKgnIPv05yUrLIao8E+LweD4L3+r\n42M+mw3E8jgOzYoD3+KnbNjxbX6CxmWDl9jwmj16hpbUByfpIoHOiY27bJjELNPY/O2lh2SwnHNH\nw8gVN/Q0OMwj1qoIMyM/444tOzp6zrhfCConQWqknu9nzX4+0mmGDPw3v6XTGMbTMLDhgYiYe6yM\noWXvDjSzQVP4ZFTStEfmakJgLfeEmLyrc25pQ88qHujCkVU4MIkaJwy97IhSEITE4FhxYMuODQ+z\nEXMYRhpC7kFByNRhwjxi8gLlPToEdPBo73FSYaXGKoOVGi+SxySf+IFfI/x+g6WOCO0xzUTdHmm6\nI3UzMIiWgS5JO1bPrLaWA43qESoiJESh8MKkY4l89ZoE9oITa48RCOkpiyzdVCCqiKwConKIyhMl\n2GBwk2GYuoXIkTm4FYSoiEoT
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094d7410>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 25
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"By contrast, the spectrum of the modulated biquad is a lot dirtier and has high energy artifacts at high modulation\n",
|
||
|
"rates. The problem gets worse at higher resonance settings."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def rbj_lpf_mat(f, res):\n",
|
||
|
" return from_biquad(rbj_lpf(f, res))\n",
|
||
|
"specgram(eval_mod(0.25 + 0.2 * sweep(n, 0.1), res, saw(0.05, n), rbj_lpf_mat))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvUmvZUt23/eLZnenu21mvi4fy2RRlgQIAgwYBAwQIDyw\nAQ00FkeENBE04VdQEf4GRo000ZBDAwJMcMoZR+bEECyyxKZenzdvc/rdRYQHsdfZcXZmsWTUe2mg\neAMI7Jt5dhM7dsR/rfVfK1aoEELguTyX5/JcnsuvddH/fzfguTyX5/JcnssPX57B/rk8l+fyXP4B\nlGewfy7P5bk8l38A5Rnsn8tzeS7P5R9AeQb75/Jcnstz+QdQnsH+uTyX5/Jc/gGUXwr2/+bf/Bte\nvXrFP/tn/+wXnvOHf/iH/PZv/zb//J//c/7iL/7ie23gc3kuz+W5PJdfvfxSsP/X//pf86d/+qe/\n8Pc/+ZM/4Wc/+xl/9Vd/xX/4D/+Bf/fv/t332sDn8lyey3N5Lr96+aVg/7u/+7tcXV39wt//03/6\nT/zBH/wBAL/zO7/D09MT33333ffXwufyXJ7Lc3kuv3L5lTn7r776itevX5/+/dlnn/Hll1/+qrd9\nLs/luTyX5/I9lu/FQTvNuKCU+j5u+1yey3N5Ls/leyr2V73Bp59+yhdffHH695dffsmnn376znnq\n5Y/h7r/+qo97Ls/luTyXf1Dlt37rt/jZz372K9/nVwb7f/kv/yU//elP+Vf/6l/x53/+51xeXvLq\n1at3T7z7r/DHIdoSFsiG+r4WhKH64bgHvkvqGwdv13CfVNcBHdAPtQRuxjpfwT8G/omCfzIcfXK6\nI7YtS+oe+H+G+l+Avwzg34B7E4/+O/hkAT9+OdaXi/joYqg58UVUADW80P/+v8F//+/hLzX8pYKg\n4HPgM+LxRfLuciyBaqizob01cIzHzLRcfPJ4qsuPnti0Kzbdim0Xj/1dTvjWEL42hG8Mlp7Z612s\nn++oPj4QlCIohq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nrYfaI\n1lPFZ+srT7U4clGtucruueKeg5mxL2bsszn7ak6jKtqmpD2UdFmJJlCohqXacqUeecmbAVSjBl1S\nU9qaSh2YZXvmsy0ax62+49bccWPecsETZhhpHZaagpyGigNLdiewX7FmyYbFQKUs2LFky4otF6y5\nZM01j9xwzxOX9FiWbFkOYB/bVFNR849+7yNK6hPYC8FQUp+1v+JI5Y+UoaYMNQVNpCOUxqtITdjg\nyX2P7RyqDSfWTA3gEDSoAVyUaMQpADtQRcDiUNpjTE/QCtN6TBfQXRgBJ7U8U4oiFQLpOQKw/fC3\nZaT5ivj83/vHRJpS6B0REDnw0eSelhGwpwzmljg/GiKV8TSM81TISBHQhdFSEAG0GNrWJe9XT54n\nwCRzRyxUOXegGU9zLBU0cg85JlTl733EKCSEblGM7IAAY0qVGVA9mA60B6vic89kcRjOzYdnLYb7\nDDRMOMZ/qm5o+xZ4ZKRlpaaWjvRjaqkM76QL4CWEq3i/cIjP8McB9AdF4EOEtHxYsK8GsK96sllL\nPquxs5bOFXTO0zqF9xade+ysI5u12FkDAfoyp8sLeqvwxpxzohoIgZP6HBwnW1edEDR+/UJBpWHh\nI+3iGOSCigPgijhoF5xrPRVQKigs2BKMjmqCMpEe0hkYjSo82aIlu67JXjTYqw7nDN4ZvI9H9z//\nj7j/XOMLiwuW4BXKBCgDahmwlx2zYs9l+cgr+x0v1bcc1IytFlhdsG+X7PMlexvwOkMrT6kaFmrH\nNQ+84rsR5IngWOqaSh+psgMzdhgcN9xzw1tuuWfJBlD0GBpyjlSUA52yHIC8x3LFE1c8cckTHs3l\nAPAXA59+Ofx2xSNXPNCRMWd/
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094cb390>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 26
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"It's visually even easier to see when the modulation has sharp steps in it."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"res = 0.1\n",
|
||
|
"specgram(eval_mod(0.15 + 0.1 * sign(sweep(n, 0.1)), res, saw(0.05, n), svf_lp))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvUmvLct15/eLJrvdnXNu81pSrBKpIgRDluAGgg0IpfLM\nNRA8MSCNBMkDQQPrGxigvoLNkQBDgCeaGhrQgmeaCa6yNXKVGqpUksjHx3e70+wmu4jwYMXKzL3v\nJWiIj08AeQKIm+fuc3Y2kRH/tdZ/NWFSSonH9tge22N7bD/Rzf5T38Bje2yP7bE9th9/ewT7x/bY\nHttj+yloj2D/2B7bY3tsPwXtEewf22N7bI/tp6A9gv1je2yP7bH9FLRHsH9sj+2xPbafgvZDwf63\nf/u3ef/99/mFX/iFH/g3v/d7v8fP/dzP8Yu/+Iv8+Z//+ed6g4/tsT22x/bYfvT2Q8H+t37rt/iT\nP/mTH/j7b33rW3z729/mr//6r/mDP/gDfvd3f/dzvcHH9tge22N7bD96+6Fg/yu/8ivc3Nz8wN//\n8R//Mb/5m78JwC//8i9ze3vL97///c/vDh/bY3tsj+2x/cjtR+bsv/vd7/LlL395+v+XvvQlvvOd\n7/yop31sj+2xPbbH9jm2z8VBe1lxwRjzeZz2sT22x/bYHtvn1PyPeoKPP/6Yf/iHf5j+/53vfIeP\nP/74rb8z5ddg+Jsf9XKP7bE9tsf2U9W++tWv8u1vf/tHPs+PDPa/9mu/xje/+U1+/dd/nT/7sz/j\n+vqa999//+0/HP4G/mWCATgs+vEdJ22AFbAB1kAJmNwtEEe4fQm3L+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D4k2FSakq6dkg
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109489510>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 27
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"specgram(eval_mod(0.15 + 0.1 * sign(sweep(n, 0.1)), res, saw(0.05, n), rbj_lpf_mat))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvVuobklW7/mLiDnnd1tr7bUvmVmZWVlVWOXx2HYhco54\n5xRC03Ae6rmEAi8oIogtjSDNobv1yfemoMF+8FGwn/ShqAZfBNuj9mnso+1ptcoLZmVV7sx9WZdv\nfd83LxGjHyLGN8c319qZZWbuLVgrIJjrMi8xY0b8xxj/MWKEExHhttyW23Jbbsu/6OL/uRtwW27L\nbbktt+X5l1uwvy235bbclm+Dcgv2t+W23Jbb8m1QbsH+ttyW23Jbvg3KLdjflttyW27Lt0G5Bfvb\ncltuy235NijvC/Y/8zM/wyuvvMJnP/vZZ57zS7/0S3znd34n3/u938uf/dmffaQNvC235bbcltvy\n4cv7gv1P//RP85WvfOWZ///yl7/M1772Nb761a/ym7/5m/zCL/zCR9rA23JbbsttuS0fvrwv2P/Y\nj/0Yd+/efeb/f+/3fo+f/MmfBOAHfuAHODs74+HDhx9dC2/Lbbktt+W2fOjyoTn7t956izfeeGP/\n+8c//nG+/vWvf9jb3pbbcltuy235CMtH4qCdZlxwzn0Ut70tt+W23Jbb8hGV6sPe4PXXX+fNN9/c\n//71r3+d119//dp57ugzcPW3H/Zxt+W23Jbb8m1VPv3pT/O1r33tQ9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aIhILh9MVrTwqmpuqgGrBS++pwKPasR06+ncFJgXwxtxTz1GqYTGpxhp0G0at0dY0\nOW7IQK8a9ZRSrM25+lwFedWk
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x10974e750>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 28
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"With very high modulation, the biquad can actually become unstable, while the state variable formulation performs fine."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"r = 0.9\n",
|
||
|
"specgram(eval_mod(0.25 + 0.185 * sign(sweep(n, 0.1)), res, saw(0.05, n), svf_lp))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvbmvPUl25/c5Ebnde9/6W6qqu7rZ3VyEkTAUZQgiBYkC\nPUEEZhw5JDAAQToEHf4Nzf+hLTq0BDqSQ4MgJEcEKA4hh5YcsYdbV3ctv+0td8vMiDhjRERm3Hyv\n2AN2VQ3QfAEE8r17b0ZGxvI953zPiQhRVeUpPaWn9JSe0k91Mv+5K/CUntJTekpP6ctPT2D/lJ7S\nU3pK/wLSE9g/paf0lJ7Sv4D0BPZP6Sk9paf0LyA9gf1TekpP6Sn9C0hPYP+UntJTekr/AtKPBfvf\n+Z3f4f333+cXf/EXP/c3v//7v88v/MIv8Eu/9Ev89V//9Rdawaf0lJ7SU3pKP3n6sWD/27/92/zZ\nn/3Z537/p3/6p3z/+9/nb/7mb/jDP/xDfu/3fu8LreBTekpP6Sk9p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mpXuWYUDK40ZBUl4RRDUAAbUgFoIMrcCCKJQ\njY569FM2PmBDwISADZqEAXD5hUMv8BWDfUuPF0ewhlBbXLA4sagKBAE1qArGekztsLXDVI6mOtKZ\nAyu7Z212rNnRcU5DwGLJPP1jYB9BYDjRGrOWs7JHmqanWo2Ieoz12C7y3o0ZHoB9x56OipqGig5B\nsQkgN2y54JbrNOmACRBLDa6l55d+7YoDh+k39aSpztQRUDC2cmKRnLEF4JJNAvs2McGuAG+XmOwb\nrrjhnHsCZtIoO464JLRm3SOb
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x1094a4550>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 29
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"specgram(eval_mod(0.25 + 0.185 * sign(sweep(n, 0.1)), res, saw(0.05, n), rbj_lpf_mat))\n",
|
||
|
"show()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvU2sLUtW5/dbEZEfe+9z7sd7r+oVPAqsgrKFWohBY9Nq\nQGLiHjBgDCNETxAThj20Go/akoc1YmCGjDxhUGKKDG08QrZsI5mCAuqB+1Hv4957ztk7PyJiebAi\nMnPvc2691/U+Sq46IcXNfe7emRkZmflfa/3XR4iqKo/tsT22x/bYfqib+0EP4LE9tsf22B7b598e\nwf6xPbbH9th+BNoj2D+2x/bYHtuPQHsE+8f22B7bY/sRaI9g/9ge22N7bD8C7RHsH9tje2yP7Ueg\nfSzY/9t/+295++23+bmf+7nX/ub3fu/3+PrXv87P//zP85d/+Zef6QAf22N7bI/tsX369rFg/9u/\n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sqEIRGmjB8zKvDf\n/kvPPCmzd2R/oW0ozK5o7ME8MyJqbLtEekb6NNLoRJsn2jjRu4n9eGI3DTQxGrWyBfct1bWdy8tt\ntXYvhiSVsgplLoLNRw6CLFRboXTKe6b1WMUykiO4W/C3m/uj8Kv/dZm/SXGDPqyl1/FXnIAzmoRT\n+U0VCFXJ3B7nAUvENxkvE13l++ux6uft81rmTxyIV1zQBcHzXtC9kPYm7CQqclLcyyIEBJoyJhcg\nF5bj89Izf3BgX6mTHfcn/4KCl16RFiQYj+vICA5Z7t6We1mfWi09L7qpOwMP3GYcfenVEfTaGd+q\nQdsn8PMyvr7YtmX+AdJmIuzd
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x109484bd0>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 30
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "heading",
|
||
|
"level": 2,
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Conclusion"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Evaluating IIR filters in matrix form yields an especially fast implementation, especially on modern SIMD processors.\n",
|
||
|
"The technique is general to many different filter design strategies.\n",
|
||
|
"\n",
|
||
|
"Given freedom of filter design strategy, a trapezoidal integrated State Variable Filter has many advantages over\n",
|
||
|
"the traditional biquad formulas. It is both more numerically robust and far more conducive to modulation, even up to\n",
|
||
|
"audio rate. It is as versatile as the traditional biquad element, and yields the same menu of \"EQ cookbook\" responses\n",
|
||
|
"without especially difficult math."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 30
|
||
|
}
|
||
|
],
|
||
|
"metadata": {}
|
||
|
}
|
||
|
]
|
||
|
}
|