| @@ -19,49 +19,47 @@ has better numerical stability. · 18 unmodified lines |
| 19 | We begin with the transfer function, described in the 1987 | 19 | We begin with the transfer function, described in the 1987 |
| 20 | paper: | 20 | paper: |
| 21 | | 21 | |
| 22 | #+BEGIN_SRC tex | 22 | |
| 23 | $$ | 23 | @!(fig "peakeq_tforiginal" |
| | 24 | `` |
| 24 | { | 25 | { |
| 25 | \alpha + \beta(1 + \alpha)z^{-1} + z^{-2} | 26 | \alpha + \beta(1 + \alpha)z^{-1} + z^{-2} |
| 26 | \over | 27 | \over |
| 27 | 1 + \beta(1 + \alpha)z^{-1} + \alpha z^{-2} | 28 | 1 + \beta(1 + \alpha)z^{-1} + \alpha z^{-2} |
| 28 | } | 29 | } |
| 29 | $$ | 30 | ``)!@ |
| 30 | #+END_SRC | | |
| 31 | | 31 | |
| 32 | This has the following difference equation: | 32 | This has the following difference equation: |
| 33 | | 33 | |
| 34 | #+BEGIN_SRC tex | 34 | @! |
| 35 | $$ | 35 | (fig "peakeq_df1_difference" |
| | 36 | `` |
| 36 | y(n) = \alpha x(n) + \beta(1 + \alpha)x(n - 1) + x(n - 2) | 37 | y(n) = \alpha x(n) + \beta(1 + \alpha)x(n - 1) + x(n - 2) |
| 37 | - \beta(1 + \alpha)z^{-1} y(n - 1) - \alpha y(n - 2) | 38 | - \beta(1 + \alpha)z^{-1} y(n - 1) - \alpha y(n - 2) |
| 38 | $$ | 39 | ``) |
| 39 | #+END_SRC | 40 | !@ |
| 40 | | 41 | |
| 41 | The | 42 | The |
| 42 | [[https://ccrma.stanford.edu/~jos/filters/Direct_Form_II.html][Direct Form II Structure]]. can be | 43 | [[https://ccrma.stanford.edu/~jos/filters/Direct_Form_II.html][Direct Form II Structure]]. can be |
| 43 | represented in this generalized difference equation: | 44 | represented in this generalized difference equation: |
| 44 | | 45 | |
| 45 | #+BEGIN_SRC tex | 46 | @!(fig "peakeq_df2_structure" |
| 46 | $$ | 47 | `` |
| 47 | v(n) = x(n) - a_1 v(n - 1) - a_2 v(n - 2) | 48 | v(n) = x(n) - a_1 v(n - 1) - a_2 v(n - 2) |
| 48 | | | |
| 49 | y(n) = b_0 v(n) + b_1 v(n - 1) + b_2 v(n - 2) | 49 | y(n) = b_0 v(n) + b_1 v(n - 1) + b_2 v(n - 2) |
| 50 | $$ | 50 | ``)!@ |
| 51 | #+END_SRC | | |
| 52 | | 51 | |
| 53 | Converting to direct form II is a matter of putting | 52 | Converting to direct form II is a matter of putting |
| 54 | coefficients in their correct places. Placing in the | 53 | coefficients in their correct places. Placing in the |
| 55 | coefficients from the Reglia and Mitra design yields the | 54 | coefficients from the Reglia and Mitra design yields the |
| 56 | following difference equation: | 55 | following difference equation: |
| 57 | | 56 | |
| 58 | #+BEGIN_SRC tex | 57 | @!(fig "peakeq_df2_difference" |
| 59 | $$ | 58 | `` |
| 60 | v(n) = x(n) - \beta(1 + \alpha)v(n - 1) - \alpha v(n - 2) | 59 | v(n) = x(n) - \beta(1 + \alpha)v(n - 1) - \alpha v(n - 2) |
| 61 | | | |
| 62 | y(n) = \alpha v(n) + \beta(1 + \alpha) v(n - 1) + v(n - 2) | 60 | y(n) = \alpha v(n) + \beta(1 + \alpha) v(n - 1) + v(n - 2) |
| 63 | $$ | 61 | `` |
| 64 | #+END_SRC | 62 | )!@ |
| 65 | | 63 | |
| 66 | Which can be translated to C code. | 64 | Which can be translated to C code. |
| 67 | * Tangled Files | 65 | * Tangled Files |
| @@ -333,11 +331,11 @@ y = eq->a*v + eq->b*(1.0 + eq->a)*eq->v[0] + eq->v[1]; · 265 unmodified lines |
| 333 | | 331 | |
| 334 | Compute the gain. This is done with the following equation: | 332 | Compute the gain. This is done with the following equation: |
| 335 | | 333 | |
| 336 | #+BEGIN_SRC tex | 334 | @!(fig "peakeq_compute_gain" |
| 337 | $$ | 335 | `` |
| 338 | y = {((x + f) + g (x - f) \over 2} | 336 | y = {(x + f) + g (x - f) \over 2} |
| 339 | $$ | 337 | `` |
| 340 | #+END_SRC | 338 | )!@ |
| 341 | | 339 | |
| 342 | #+NAME: compute_gain | 340 | #+NAME: compute_gain |
| 343 | #+BEGIN_SRC c | 341 | #+BEGIN_SRC c |