lasp/examples/test_SLM.ipynb

104 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

{
"cells": [
2022-10-10 17:29:24 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test SLM (Sound Level Meter)"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"from lasp import SLM as SLM\n",
"from lasp import TimeWeighting, FreqWeighting\n",
"from lasp.filter import ThirdOctaveBankDesigner\n",
"import numpy as np\n",
2022-10-10 17:29:24 +00:00
"# %pylab inline"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"fs = 48000.\n",
"Lref = 1\n",
"ds = 1\n",
"tau = 1/8\n",
"\n",
2022-10-10 17:29:24 +00:00
"designer = ThirdOctaveBankDesigner(fs)\n",
"slm = SLM(fs,\n",
" designer,\n",
" level_ref_value=1\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"x = np.zeros((20100,1), dtype=float)\n",
"x[:] = 1\n",
"\n",
"res = slm.run(x)\n",
"print(res.shape)"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
2022-10-10 17:29:24 +00:00
"res"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"slm.Pm"
]
},
{
"cell_type": "code",
2022-10-10 17:29:24 +00:00
"execution_count": null,
"metadata": {},
2022-10-10 17:29:24 +00:00
"outputs": [],
"source": [
"res[-1,:]"
]
}
],
"metadata": {
"kernelspec": {
2022-10-10 17:29:24 +00:00
"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",
2022-10-10 17:29:24 +00:00
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}