lasp/examples/Test SLM.ipynb

201 lines
15 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"source": [
"from lasp import SLM\n",
"import numpy as np\n",
"%pylab inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-09-03 17:21:56+0200 DebugTrace-cpp 2.0.0a2 (g++ 12.2.0)\n",
"2022-09-03 17:21:56+0200 \n",
"2022-09-03 17:21:56+0200 Enter SeriesBiquad (lasp_biquadbank.cpp: 12)\n",
"2022-09-03 17:21:56+0200 Leave SeriesBiquad (lasp_biquadbank.cpp)\n",
"2022-09-03 17:21:56+0200 \n",
"2022-09-03 17:21:56+0200 Enter SeriesBiquad (lasp_biquadbank.cpp: 12)\n",
"2022-09-03 17:21:56+0200 Leave SeriesBiquad (lasp_biquadbank.cpp)\n"
]
}
],
"source": [
"fs = 44100.\n",
"Lref = 1\n",
"ds = 1\n",
"tau = 1/8\n",
"\n",
"bp_coefs = np.zeros((6,2), order='F')\n",
"bp_coefs[0,:] = 1\n",
"bp_coefs[3,:] = 1\n",
"\n",
"slm = SLM.fromBiquads(\n",
" fs, \n",
" Lref,\n",
" ds, tau, bp_coefs\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 1.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [1., 1.],\n",
" [0., 0.],\n",
" [0., 0.]])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bp_coefs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x = np.zeros(20100, dtype=float)\n",
"x[:] = 1\n",
"\n",
"res = slm.run(x)\n",
"print(res.shape)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f3823125cf0>,\n",
" <matplotlib.lines.Line2D at 0x7f3823125d50>]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD6CAYAAACvZ4z8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAfnElEQVR4nO3deZCc9X3n8fe3j7lHtzSSkJBkLlkcEswgwCbAsJgI1jZZh2zAtap1YqItOzh2xVVZO/zBOsdWUuV12btmnWDD2lljz3qNMcYhxrAeoWDMoRESCB0gJIE0OkZC0mh67u7nu390Sx5pDvU53fPo86rqmunn6X5+n+luPnr49dNPm7sjIiLhFSl3ABERKS0VvYhIyKnoRURCTkUvIhJyKnoRkZCLlTvAWObMmeNLly7N6769vb3U19cXN1ARKFf2KjETKFeulCs3hebq6Og46u5zx1zp7hV3aW5u9ny1t7fnfd9SUq7sVWImd+XKlXLlptBcwEYfp1M1dSMiEnIqehGRkFPRi4iEnIpeRCTkVPQiIiFX8qI3szVmttPMdpnZl0o9noiInKmkRW9mUeAh4A5gBXCvma0o5ZgiInKmUn9gajWwy913A5hZG3AXsK3E44rIeShIpUilkqRSSYJUklQqRZAcTl8PUgSpFH0nDnNgzw5SqWGCVAoPkgSpFEHmPkGQhFQqffsgiaeSeCqFexJPBQRBCjyFB57+6QEEKTwIcA8wT//0IAUegAd4EJz+HU/B6ds67ilwZ+D4+7y071dcv/aviv64mJfwfPRmdjewxt3vy1xfC1zn7vePcdt1wDqApqam5ra2trzGTCQSNDQ05B+6RJQre5WYCcKXy4MgU37DBMnh9M/UcKbYhvHUEJ5KQjAMqeH0zyAFQ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9gIeli3zGzlciyG1m06jYWXniJ3iAVkVFU9BWqp/sYO//1x0R2PMXynpdZaYP0exVv1a6kc8l/4IKWj7LooitZqD12ETkHFX0FSZw8zrb/932q3/oZH+zbRIslOcoM3phzB7VXfpxLr1vDytr6cscUkSlGRV9mqWSSbb/+GYMdj3F59wZW2xAHbB6b5v8BM5p/n0ubb2WO3iwVkQKo6Mvk0L5d7PnFN7m486dcyXFOUs/rc+5k+vVruaz5Vk3JiEjRqOgnkQcBW194iuRL/8hVvS8yF3ij7jr2r/okK27+A66r0XkXRaT4VPSTYHhokO7tz/Huhs9xZfAex5nGKxesZenv3s+qJTp5l4iUloq+hAb6e9ny1EMs3v5t7vIu9kSW8Oqq/8qVv/spbtCbqiIySVT0JZAcHuK1p77Fkte/znUcY2dsOU8u+GM+9qm/YJneWBWRSVbyojezvUAPkAKS7t5S6jHLxYOALb/6P8x48W+5NtjHzthyum75Bpd/6KMc3LBBpxoQkbKYrD36Vnc/OkljlcX+XVs59uM/Y9VAB/tsIa/d8N9Z9ZG1mI6eEZEyM3cv7QDpPfqWcxW9ma0D1gE0NTU1t7W15TVeIpGgoWHyvnwuOTzI8Bs/5tbuJxgixvrZ91K34k6isXhZc2WrEnNVYiZQrlwpV24KzdXa2tox7oyJu5f0AuwBNgEdwLps7tPc3Oz5am9vz/u+uXp78wu+5yuXuz84zTd+9ff8SOfeisiVi0rMVYmZ3JUrV8qVm0JzARt9nE4teOrGzJ4D5o+x6gF3fxK40d07zWwe8KyZ7XD3DYWOW06pZJJXHnuQ5t3f4oRN5/WbH6G59e5yxxIRGVPBRe/ut51jfWfmZ5eZPQGsBqZs0R/r6uTgd+7lhqEtbGq8mYv+6NtcNbvp3HcUESmTkr5TaGb1ZtZ46nfgdmBrKccspbc2Pc/Q/7yJiwa38crKv+bqP/8p01XyIlLhSn3UTRPwhJmdGus
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot(res)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1.],\n",
" [1.]])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"slm.Pm"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-0.11480531, -0.11480531])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res[-1,:]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}