Skip to content

Instantly share code, notes, and snippets.

@jkbd
Created September 7, 2022 17:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jkbd/07521a98f7873a2dc3dbe16417930791 to your computer and use it in GitHub Desktop.
How to reconstruct filter parameters
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "b9568aa6",
"metadata": {},
"source": [
"# How to reconstruct filter parameters\n",
"\n",
"The [RECOMMENDATION ITU-R BS.1770-4](https://www.itu.int/rec/R-REC-BS.1770) defines a pre-filter as two biquads.\n",
"The coefficients for stage1 and stage2 at a samplerate of 48kHz are given on pages 4-5. We translate those tables to Python as:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5b1f8379",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"stage1 = np.array([\n",
" 1.53512485958697, # b_0\n",
" -2.69169618940638, # b_1\n",
" 1.19839281085285, # b_2\n",
" 1.0,\n",
" -1.69065929318241, # a_1\n",
" 0.73248077421585, # a_2\n",
"])\n",
"\n",
"stage2 = np.array([\n",
" 1.0, # b_0\n",
" -2.0, # b_1\n",
" 1.0, # b_2\n",
" 1.0,\n",
" -1.99004745483398, # a_1\n",
" 0.99007225036621, # a_2\n",
"])"
]
},
{
"cell_type": "markdown",
"id": "c8570625",
"metadata": {},
"source": [
"For other samplerates then `samplerate = 48000` we need to construct filters with a similar frequency response."
]
},
{
"cell_type": "markdown",
"id": "cc2d9a1f",
"metadata": {},
"source": [
"## First attempt"
]
},
{
"cell_type": "markdown",
"id": "60379ab0",
"metadata": {},
"source": [
"How to calculate the coefficients of digital filters is given in\n",
"\"DAFX: Digital Audio Effects\" (Udo Zölzer 2011, 2. edition).\n",
"Table 2.3 on page 64 defines coefficients for second-order high-frequency boost shelving filters (`stage1`) and\n",
"Table 2.2 on page 50 defines coefficients for second-order highpass filters (`stage2`).\n",
"\n",
"We invent two functions to calculate the second-order-sections:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9c048003",
"metadata": {},
"outputs": [],
"source": [
"def hf_boost_shelv(K, V_0):\n",
" \"\"\"Calculate coefficients for a second-order high-frequency boost shelving filter.\"\"\"\n",
" denominator = (1 + np.sqrt(2)*K + K**2)\n",
" b_0 = (V_0 + np.sqrt(2*V_0)*K + K**2) / denominator\n",
" b_1 = 2*(K**2 - V_0) / denominator\n",
" b_2 = (V_0 - np.sqrt(2*V_0)*K + K**2) / denominator \n",
" \n",
" a_1 = 2*(K**2 - 1) / denominator\n",
" a_2 = (1 - np.sqrt(2)*K + K**2) / denominator\n",
"\n",
" return np.array([b_0, b_1, b_2, 1.0, a_1, a_2])\n",
"\n",
"\n",
"def highpass(K, Q):\n",
" \"\"\"Calculate coefficients for a second-order highpass filter.\"\"\"\n",
" denominator = ((K**2) * Q + K + Q)\n",
" b_0 = Q / denominator\n",
" b_1 = -2*Q / denominator\n",
" b_2 = b_0\n",
" \n",
" a_1 = (2*Q * (K**2 - 1)) / denominator\n",
" a_2 = ((K**2) * Q - K + Q) / denominator\n",
"\n",
" return np.array([b_0, b_1, b_2, 1.0, a_1, a_2])"
]
},
{
"cell_type": "markdown",
"id": "179085ff",
"metadata": {},
"source": [
"`K` is defined as `K = np.tan(np.pi * f_c / samplerate)`, thus"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ce33abec",
"metadata": {},
"outputs": [],
"source": [
"def cutoff_freq(K, samplerate):\n",
" \"\"\"Return the cutoff frequency in Hertz.\"\"\"\n",
" return (samplerate * np.arctan(K))/np.pi"
]
},
{
"cell_type": "markdown",
"id": "f857eceb",
"metadata": {},
"source": [
"`V_0` is defined as `V_0 = np.power(10.0, G / 20.0)`, where `G` is a gain we are not interested in."
]
},
{
"cell_type": "markdown",
"id": "25985191",
"metadata": {},
"source": [
"Now we can try to find values for `K`, `Q` and `V_0`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "51da6f3c",
"metadata": {},
"outputs": [],
"source": [
"from scipy.optimize import minimize\n",
"\n",
"def solve_stage1(samplerate):\n",
" \"\"\"Minimize the difference between target biquad and calculated biquad.\"\"\"\n",
" def helper1(z):\n",
" K = z[0]\n",
" V_0 = z[1]\n",
" sos = hf_boost_shelv(K, V_0)\n",
" \n",
" result = np.sum(np.square(stage1 - sos))\n",
" return result\n",
" \n",
" guess = np.array([1.0, 1.0], dtype=np.float64)\n",
" result = minimize(helper1, guess, tol=1e-11)\n",
" return result"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a907cdaa",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" fun: 1.2547183412375365e-09\n",
" hess_inv: array([[0.03148047, 0.0707926 ],\n",
" [0.0707926 , 0.27269465]])\n",
" jac: array([ 7.18314297e-14, -5.01126918e-14])\n",
" message: 'Optimization terminated successfully.'\n",
" nfev: 36\n",
" nit: 9\n",
" njev: 12\n",
" status: 0\n",
" success: True\n",
" x: array([0.11051784, 1.58485266])\n",
"freq = 1681.7632251028442 Hz\n",
"V_0 = 3.9997778685513232 dB\n"
]
}
],
"source": [
"samplerate = 48000\n",
"\n",
"result = solve_stage1(samplerate)\n",
"print(result)\n",
"\n",
"K1, V_0 = result.x\n",
"\n",
"print(f'freq = {cutoff_freq(K1, samplerate)} Hz')\n",
"print(f'V_0 = {20.0 * np.log10(np.abs(V_0))} dB')"
]
},
{
"cell_type": "markdown",
"id": "140e6974",
"metadata": {},
"source": [
"Let's look at the coefficient errors:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "757afe31",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[-1.74123774e-05 2.54301517e-06 2.51807174e-05 0.00000000e+00\n",
" 1.65097513e-05 -6.19839611e-06]\n"
]
}
],
"source": [
"err = stage1 - hf_boost_shelv(*result.x)\n",
"print(err)"
]
},
{
"cell_type": "markdown",
"id": "eefc3ddc",
"metadata": {},
"source": [
"Okay.\n",
"\n",
"Now we repeat that for the second stage."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "38d47933",
"metadata": {},
"outputs": [],
"source": [
"def solve_stage2(samplerate):\n",
" \"\"\"Minimize the difference between target biquad and calculated biquad.\"\"\"\n",
" def helper2(z):\n",
" K = z[0]\n",
" Q = z[1]\n",
" sos = highpass(K, Q)\n",
" result = np.sum(np.square(stage2 - sos))\n",
" return result\n",
" \n",
" guess = np.array([0.002, 0.25], dtype=np.float64)\n",
" result = minimize(helper2, guess, tol=1e-09)\n",
" return result"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c6c1af49",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" fun: 8.469157205235147e-05\n",
" hess_inv: array([[0.00227113, 0.01264941],\n",
" [0.01264941, 1.00309113]])\n",
" jac: array([9.96333256e-08, 9.05220077e-09])\n",
" message: 'Desired error not necessarily achieved due to precision loss.'\n",
" nfev: 159\n",
" nit: 5\n",
" njev: 49\n",
" status: 2\n",
" success: False\n",
" x: array([0.00070414, 0.24727469])\n",
"freq = 10.758482410249737 Hz\n",
"Q = 0.2472746919148863\n"
]
}
],
"source": [
"result = solve_stage2(samplerate)\n",
"print(result)\n",
"\n",
"K2, Q = result.x\n",
"print(f'freq = {cutoff_freq(K2, samplerate)} Hz')\n",
"print(f'Q = {Q}')"
]
},
{
"cell_type": "markdown",
"id": "95887f38",
"metadata": {},
"source": [
"The errors:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "deb8ab24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0.00284001 -0.00568003 0.00284001 0. 0.00427153 -0.00424871]\n"
]
}
],
"source": [
"err = stage2 - highpass(*result.x)\n",
"print(err)"
]
},
{
"cell_type": "markdown",
"id": "a474ffba",
"metadata": {},
"source": [
"Now let's have a look at the transfer functions."
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a95cfb1b",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_28555/4003190015.py:16: RuntimeWarning: divide by zero encountered in log10\n",
" ax1.plot(w, 20 * np.log10(abs(h)), label='EBU')\n",
"/tmp/ipykernel_28555/4003190015.py:17: RuntimeWarning: divide by zero encountered in log10\n",
" ax1.plot(w2, 20 * np.log10(abs(h2)), label='jkbd')\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEaCAYAAAD65pvjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA330lEQVR4nO3dd5xU5fX48c/ZXmFhl74sIFJFpCzYgiBBY0eNsQQLNtREExNb1JivmpiYxCTKz4oFjTVERcCKqNjpRTrSWeqysL3vnN8f9y4ZtzG7O7MzO3ver9e8dm577pm5cM88z3Pvc0VVMcYYY7xFBDsAY4wxoceSgzHGmFosORhjjKnFkoMxxphaLDkYY4ypxZKDMcaYWiw5GABE5GkRuc/f69azvYrI0fUs6yIiX4hIgYj8Q0TuEZHn3GW93W2jmrpvH2L7wf4DtR9jQl3A/pOZ0CEi24AuQCVQBawF/g1MU1UPgKre6Gt53uuKyDjgFVVN91O4U4ADQDs9wk04IjLf3fdzftp3o/ZvTDizmkPbca6qJgO9gIeBu4DngxtSnXoBa1vixCwikY3dfyBrLaGonu/ItAWqaq8wfwHbgAk15o0GPMAQd/pF4E9ey+8E9gC7gesABY72XhdIBErccgrdV3e37G+BXLeMx4EYr7IPl1UjpheBCqDcLWsCcD9O7QCgt7ttFPAQTi2o1F33cXedgcDHwEFgA3BxjfKfAt4Hiur4Turb/5vAK0C++120x0mse4Bd7ncR6ZYRCTyCU/vYAvyyOua6joX353OnTwC+cb+7lcA4r2XzgT8CXwMFwFwgzWv5j7y23QlMBkYB+6r37673U2BFPf9Wan1H7jF9C8gGtgK/qvHvaIn73ewD/lnjWE3B+Te0B7jNa7tY4F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
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import scipy\n",
"\n",
"target_sos = np.vstack( (np.array([stage1]), np.array([stage2])) )\n",
"w, h = scipy.signal.sosfreqz(target_sos, worN=2**20, fs=samplerate)\n",
"\n",
"calculated_sos = np.vstack(\n",
" (np.array(hf_boost_shelv(K1, V_0)),\n",
" np.array(highpass(K2, Q)))\n",
")\n",
"w2, h2 = scipy.signal.sosfreqz(calculated_sos, worN=2**20, fs=samplerate)\n",
"\n",
"fig, ax1 = plt.subplots()\n",
"ax1.set_title('Digital filter frequency response')\n",
"\n",
"ax1.plot(w, 20 * np.log10(abs(h)), label='EBU')\n",
"ax1.plot(w2, 20 * np.log10(abs(h2)), label='jkbd')\n",
"\n",
"ax1.set_xlabel('Frequency [Hz]')\n",
"ax1.set_xscale('log')\n",
"ax1.set_ylabel('Magnitude [dB]')\n",
"\n",
"plt.xlim(20, samplerate/2.0)\n",
"plt.ylim(-12, 6)\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "0ff1320e",
"metadata": {},
"source": [
"Is there something wrong with highpass filter?\n",
"\n",
"Looks like the optimisation of the second filter is weak. The result depends heavily on the initial guess."
]
},
{
"cell_type": "markdown",
"id": "5510b831",
"metadata": {},
"source": [
"## Second try"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a114569c",
"metadata": {},
"outputs": [],
"source": [
"from scipy.optimize import fsolve\n",
"\n",
"def solve_stage2(samplerate):\n",
" \"\"\"Minimize the difference between target biquad and calculated biquad.\"\"\"\n",
" def helper(z):\n",
" K = z[0]\n",
" Q = z[1]\n",
" sos = highpass(K, Q)\n",
" result = stage2[4:] - sos[4:]\n",
" return result\n",
" \n",
" guess = np.array([0.002, 0.25], dtype=np.float64)\n",
" result = fsolve(helper, guess)\n",
" return result"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "28c61d50",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.00249597 0.50032704]\n",
"freq = 38.135470876002174 Hz\n",
"Q = 0.5003270373223665\n"
]
}
],
"source": [
"result = solve_stage2(samplerate)\n",
"print(result)\n",
"\n",
"K2, Q = result\n",
"print(f'freq = {cutoff_freq(K2, samplerate)} Hz')\n",
"print(f'Q = {Q}')"
]
},
{
"cell_type": "markdown",
"id": "a2517242",
"metadata": {},
"source": [
"Frequency response, again:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "b3f94c6d",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_28555/1576023010.py:13: RuntimeWarning: divide by zero encountered in log10\n",
" ax1.plot(w, 20 * np.log10(abs(h)), label='EBU')\n",
"/tmp/ipykernel_28555/1576023010.py:14: RuntimeWarning: divide by zero encountered in log10\n",
" ax1.plot(w2, 20 * np.log10(abs(h2)), label='jkbd')\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEaCAYAAAD65pvjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAzPElEQVR4nO3deXwV5bnA8d9zshMSlhCWEAIooIh4UYIbioi4b3WpiivqFW2L1V61brXVWlvvrbXWpSpu4FKtCoq7iIoLoAICsrkAIoSwBpKQPTnnuX/MQA/ZOAk5mbM838/nfHJme9/nzOTMc+admXdEVTHGGGOC+bwOwBhjTOSx5GCMMaYBSw7GGGMasORgjDGmAUsOxhhjGrDkYIwxpgFLDgYAEXlMRO5o63mbWF5FZEAT03qIyKciskNE/iYit4nIk+60fu6yia2tO4TYdqs/XPUYE+nC9iUzkUNE1gA9gDrADywHngUmqWoAQFWvCbW84HlFZDTwvKrmtlG4E4CtQKbu4SYcEZnl1v1kG9XdovqNiWV25BA/TlfVDKAvcC9wM/CUtyE1qi+wvD12zC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OS0RETsTlfTYnbkYGJNmogsct//CPwG2A+4XFV/6T4GdSBOv/sCvCEio4BynH5wDsb5XnwNLNhDXVcCJao6QkRSgNkiMsOddjAwBKfTtdnASBH5Cvg3cL6qzhORTKASeBLnKXzXi8ggIEVVvwnhsx4d9FkB8oC3VHU+MAycpiTgvRDKMmY3lhxMrNmtWck95/CTqn7hjjrBfS10hzviJIsM4DVVrXCXC6WztBOAg4La+Tu5ZdUAX6lqgVvWIqAfUAJsUNV5AKpa6k5/BbhDRG4CrsB5wlgoPlPVXc8jFpHdlhOR84BD3DiNaRFLDiYeBLezC/AXVX08eAYRuZ6gfvfrqeM/TbCp9cq6VlXfr1fWaKA6aJQf57smjdWhqhUi8gHOE8Pa5JnQIjIEuAsYpar+vS3PxB8752DizfvAFSLSEUBEeotId+BT4CwRSRORDOD0oGXWAMPd9+fWK+sXIpLkljVIRNKbqftbIEdERrjzZ4jIzh9oT+I8cGmeqtZ/9GSLiEgnnMdTXqqqW/amLBO/7MjBxBVVnSEig4G57jniMuBiVf1aRP4NLAJ+Aj4LWuw+4GURuQT4KGj8kzjNRV+7J5y3AD9rpu4aETkfeEhE0nDON4wFylR1gYiUAs+0wcf8GdAXeML9jDR1BZcxTbEuu41phIjcibPTvq+d6svBeezn/o1daus+ezh/by5ldcu5k3b8XCZ6WbOSMR4TkUuBL4Hbm7kHoxI4eedNcK2s56/Axex+DsaYRtmRgzHGmAbsyMEYY0wDlhyMMcY0YMnBGGNMA5YcjDHGNGDJwRhjTAOWHIwxxjTw/9BP8+yoHTgcAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"target_sos = np.vstack( (np.array([stage1]), np.array([stage2])) )\n",
"w, h = scipy.signal.sosfreqz(target_sos, worN=2**20, fs=samplerate)\n",
"\n",
"calculated_sos = np.vstack(\n",
" (np.array(hf_boost_shelv(K1, V_0)),\n",
" np.array(highpass(K2, Q)))\n",
")\n",
"w2, h2 = scipy.signal.sosfreqz(calculated_sos, worN=2**20, fs=samplerate)\n",
"\n",
"fig, ax1 = plt.subplots()\n",
"ax1.set_title('Digital filter frequency response')\n",
"\n",
"ax1.plot(w, 20 * np.log10(abs(h)), label='EBU')\n",
"ax1.plot(w2, 20 * np.log10(abs(h2)), label='jkbd')\n",
"\n",
"ax1.set_xlabel('Frequency [Hz]')\n",
"ax1.set_xscale('log')\n",
"ax1.set_ylabel('Magnitude [dB]')\n",
"\n",
"plt.xlim(20, samplerate/2.0)\n",
"plt.ylim(-12, 6)\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "ae6c75dd",
"metadata": {},
"source": [
"What is the maximum difference beween the spectra?"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "2acb641b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.04334313168283899 dB\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_28555/3750599922.py:1: RuntimeWarning: divide by zero encountered in log10\n",
" diffs = np.abs(20 * np.log10(abs(h)) - 20 * np.log10(abs(h2)))\n",
"/tmp/ipykernel_28555/3750599922.py:1: RuntimeWarning: invalid value encountered in subtract\n",
" diffs = np.abs(20 * np.log10(abs(h)) - 20 * np.log10(abs(h2)))\n"
]
}
],
"source": [
"diffs = np.abs(20 * np.log10(abs(h)) - 20 * np.log10(abs(h2)))\n",
"m = np.max(diffs[np.logical_not(np.isnan(diffs))])\n",
"print(f'{m} dB')"
]
},
{
"cell_type": "markdown",
"id": "475e7e00",
"metadata": {},
"source": [
"## Is it correct for other samplerates?"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "1aebcd19",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_28555/1822753161.py:23: RuntimeWarning: divide by zero encountered in log10\n",
" ax1.plot(w, 20 * np.log10(abs(h)))\n"
]
},
{
"data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zK4nZtz9Rmr5dxNsl0Zlfc3dn2tU1klAVcysOoLPmjVXh7tXmNkMgjuGtcs9oc1sAvAj4OPuXneg5Unm0TkHyTTPAVeZWSGAmQ02s/7AK8B5ZtbVzLoDZ8dsswo4Onz+2UZlXWtmuWFZY8ysIE7dy4BBZnZMuH53M2v4gXYXwQ2XZrt741tPtoqZ9SS4PeUX3X3zgZQlmUtHDpJR3P15MxsHzArPEe8GLnX3eWb2MDAfWA28GrPZr4FHzOwy4IWY+XcRNBfNC084bwY+E6fuajP7AvA/ZtaV4HzDFGC3u881s3Lg7nZ4mZ8BhgF3hq+RlnpwibREQ3aLNMPMfkjwpf3rDqpvEMFtP8c219U2vPdwyYF0ZQ3L+SEd+LokfalZSSRiZvZF4C3gpjjXYOwFPt1wEVwb6/kVcCkfPQcj0iwdOYiISBM6chARkSaUHEREpAklBxERaULJQUREmlByEBGRJpQcRESkif8PUXPwxwU2f0MAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"samplerate = 48000\n",
"\n",
"def decibel2factor(decibel):\n",
" return np.power(10, (decibel/20.0))\n",
"\n",
"def freq2k(freq, samplerate):\n",
" return np.tan(np.pi * freq / samplerate)\n",
"\n",
"K1 = freq2k(1681.7632251028442, samplerate)\n",
"V_0 = decibel2factor(3.9997778685513232)\n",
"K2 = freq2k(38.135470876002174, samplerate)\n",
"Q = 0.5003270373223665\n",
" \n",
"sos = np.vstack(\n",
" (np.array(hf_boost_shelv(K1, V_0)),\n",
" np.array(highpass(K2, Q)))\n",
")\n",
"w, h = scipy.signal.sosfreqz(sos, worN=2**20, fs=samplerate)\n",
"\n",
"fig, ax1 = plt.subplots()\n",
"ax1.set_title('Digital filter frequency response')\n",
"\n",
"ax1.plot(w, 20 * np.log10(abs(h)))\n",
"\n",
"ax1.set_xlabel('Frequency [Hz]')\n",
"ax1.set_xscale('log')\n",
"ax1.set_ylabel('Magnitude [dB]')\n",
"\n",
"plt.xlim(20, samplerate/2.0)\n",
"plt.ylim(-12, 6)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "2edea3a6",
"metadata": {},
"source": [
"Looks okay."
]
},
{
"cell_type": "markdown",
"id": "c271b8ea",
"metadata": {},
"source": [
"The magnitude at 997Hz is:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "9e6afe43",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(array([ 997., 1000.]), array([1.07762056, 1.07845159]))\n",
"1.0776205611408702\n",
"1.0784515947925883\n"
]
}
],
"source": [
"w2, h2 = scipy.signal.sosfreqz(sos, np.array([997.0, 1000.0]),\n",
" fs=samplerate)\n",
"print((w2, np.abs(h2)))\n",
"for mag in np.abs(h2):\n",
" print(mag)"
]
},
{
"cell_type": "markdown",
"id": "3a353372",
"metadata": {},
"source": [
"So we need to normalize with the factor"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "505a11c2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9273671710547968"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1/1.0783215442731167"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6e449a6",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment