Removed old testing code. Improved Doxyfile, added logo to Doxygen. Added pytest testing config.
This commit is contained in:
parent
f8e8ab422b
commit
34239bfabf
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,3 +19,4 @@ src/lasp.egg-info
|
|||||||
test/.ipynb_checkpoints
|
test/.ipynb_checkpoints
|
||||||
src/lasp/lasp_config.h
|
src/lasp/lasp_config.h
|
||||||
_deps
|
_deps
|
||||||
|
.ipynb_checkpoints
|
||||||
|
8
Doxyfile
8
Doxyfile
@ -1,4 +1,4 @@
|
|||||||
# Doxyfile 1.9.3
|
# Doxyfile 1.8.17
|
||||||
|
|
||||||
# This file describes the settings to be used by the documentation system
|
# This file describes the settings to be used by the documentation system
|
||||||
# doxygen (www.doxygen.org) for a project.
|
# doxygen (www.doxygen.org) for a project.
|
||||||
@ -38,20 +38,20 @@ PROJECT_NAME = LASP
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER =
|
PROJECT_NUMBER = 1.0
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
# quick idea about the purpose of the project. Keep the description short.
|
# quick idea about the purpose of the project. Keep the description short.
|
||||||
|
|
||||||
PROJECT_BRIEF =
|
PROJECT_BRIEF = "Library for Acoustic Signal Processing"
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||||
# in the documentation. The maximum height of the logo should not exceed 55
|
# in the documentation. The maximum height of the logo should not exceed 55
|
||||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||||
# the logo to the output directory.
|
# the logo to the output directory.
|
||||||
|
|
||||||
PROJECT_LOGO =
|
PROJECT_LOGO = /home/anne/wip/mycode/lasp/img/LASP_200px.png
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||||
# into which the generated documentation will be written. If a relative path is
|
# into which the generated documentation will be written. If a relative path is
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
set(default_build_type "Release")
|
set(default_build_type "Release")
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
|
||||||
STRING "Choose the type of build." FORCE)
|
|
||||||
|
|
||||||
# Set the possible values of build type for cmake-gui
|
# Set the possible values of build type for cmake-gui
|
||||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
|
||||||
endif()
|
endif()
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
||||||
|
229
examples/Test SLM.ipynb
Normal file
229
examples/Test SLM.ipynb
Normal file
File diff suppressed because one or more lines are too long
113
examples/Test SeriesBiquad.ipynb
Normal file
113
examples/Test SeriesBiquad.ipynb
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from lasp import SeriesBiquad\n",
|
||||||
|
"import numpy as np"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"2022-08-16 15:02:57+0200 \n",
|
||||||
|
"2022-08-16 15:02:57+0200 Enter SeriesBiquad (lasp_biquadbank.cpp: 12)\n",
|
||||||
|
"2022-08-16 15:02:57+0200 Leave SeriesBiquad (lasp_biquadbank.cpp)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"coefs = np.array([1.,0,0,1.,-.9,0])\n",
|
||||||
|
"bq = SeriesBiquad(coefs)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"2022-08-16 15:02:57+0200 \n",
|
||||||
|
"2022-08-16 15:02:57+0200 Enter filter (lasp_biquadbank.cpp: 41)\n",
|
||||||
|
"2022-08-16 15:02:57+0200 Leave filter (lasp_biquadbank.cpp)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"x = np.zeros(10, dtype=float)\n",
|
||||||
|
"x[0] = 1\n",
|
||||||
|
"\n",
|
||||||
|
"x2 = bq.filter(x)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"array([[1. ],\n",
|
||||||
|
" [0.9 ],\n",
|
||||||
|
" [0.81 ],\n",
|
||||||
|
" [0.729 ],\n",
|
||||||
|
" [0.6561 ],\n",
|
||||||
|
" [0.59049 ],\n",
|
||||||
|
" [0.531441 ],\n",
|
||||||
|
" [0.4782969 ],\n",
|
||||||
|
" [0.43046721],\n",
|
||||||
|
" [0.38742049]])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"x2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"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.8.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
|
}
|
168
examples/Test input.ipynb
Normal file
168
examples/Test input.ipynb
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b0d15138",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"!make -j -C ~/wip/mycode/lasp"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "1787e24c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import lasp\n",
|
||||||
|
"ds = lasp.DeviceInfo.getDeviceInfo()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "22ae99b1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"for i, d in enumerate(ds):\n",
|
||||||
|
" print(f'{i}: ' + d.device_name)\n",
|
||||||
|
"d = ds[1]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b1321c4a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"d.availableFramesPerBlock"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "47385b02",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"config = lasp.DaqConfiguration(d)\n",
|
||||||
|
"config.inchannel_config[0].enabled = True\n",
|
||||||
|
"config.inchannel_config[1].enabled = True\n",
|
||||||
|
"config.framesPerBlockIndex = 4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d12f84b7",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"print('Out channels:',d.noutchannels)\n",
|
||||||
|
"print('In channels:',d.ninchannels)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "902ce309",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"mgr = lasp.StreamMgr.getInstance()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b209294b",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"mgr.startStream(d, config)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "0830ffb5",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"mgr.stopStream(lasp.StreamMgr.StreamType.input)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "a7fddc19",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"mgr.stopAllStreams()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d11c7dae",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def cb(data):\n",
|
||||||
|
" # raise RuntimeError('hh')\n",
|
||||||
|
" print(data.shape)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "0eeb2311",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"i = lasp.InDataHandler(mgr, cb)\n",
|
||||||
|
"import time\n",
|
||||||
|
"#time.sleep(4)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f893b639",
|
||||||
|
"metadata": {
|
||||||
|
"scrolled": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"del i"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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
|
||||||
|
}
|
BIN
img/LASP.pdf
BIN
img/LASP.pdf
Binary file not shown.
BIN
img/LASP_200px.png
Normal file
BIN
img/LASP_200px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
2
pytest.ini
Normal file
2
pytest.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[pytest]
|
||||||
|
addopts = "--ignore=third_party"
|
@ -5,8 +5,12 @@ add_definitions(-DARMA_DONT_USE_WRAPPER)
|
|||||||
|
|
||||||
configure_file(lasp_config.h.in lasp_config.h)
|
configure_file(lasp_config.h.in lasp_config.h)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
include_directories(SYSTEM ../../third_party/armadillo-code/include)
|
|
||||||
include_directories(SYSTEM ../../third_party/carma/include)
|
include_directories(SYSTEM ../../third_party/carma/include)
|
||||||
|
include_directories(SYSTEM
|
||||||
|
../../third_party/carma/extern/armadillo-code/include)
|
||||||
|
include_directories(SYSTEM
|
||||||
|
../../third_party/carma/extern/pybind11/include)
|
||||||
|
|
||||||
include_directories(../../third_party/DebugTrace-cpp/include)
|
include_directories(../../third_party/DebugTrace-cpp/include)
|
||||||
include_directories(../../third_party/lockfreeThreadsafe/include)
|
include_directories(../../third_party/lockfreeThreadsafe/include)
|
||||||
include_directories(../../third_party/gsl-lite/include)
|
include_directories(../../third_party/gsl-lite/include)
|
||||||
@ -26,6 +30,8 @@ pybind11_add_module(lasp_cpp MODULE lasp_cpp.cpp
|
|||||||
pybind11/lasp_pyindatahandler.cpp
|
pybind11/lasp_pyindatahandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(lasp_cpp PRIVATE lasp_device_lib lasp_dsp_lib)
|
target_link_libraries(lasp_cpp PRIVATE lasp_device_lib lasp_dsp_lib
|
||||||
|
carma::carma
|
||||||
|
${OpenMP_CXX_LIBRARIES} ${LASP_FFT_LIBS})
|
||||||
|
|
||||||
install(TARGETS lasp_cpp DESTINATION .)
|
install(TARGETS lasp_cpp DESTINATION .)
|
||||||
|
@ -1,250 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"id": "b0d15138",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"make: Entering directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"make[1]: Entering directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"make[2]: Entering directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"\u001b[35m\u001b[1mConsolidate compiler generated dependencies of target lasp_dsp_lib\u001b[0m\n",
|
|
||||||
"make[2]: Leaving directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"[ 26%] Built target lasp_dsp_lib\n",
|
|
||||||
"make[2]: Entering directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"\u001b[35m\u001b[1mConsolidate compiler generated dependencies of target lasp_device_lib\u001b[0m\n",
|
|
||||||
"make[2]: Leaving directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"[ 63%] Built target lasp_device_lib\n",
|
|
||||||
"make[2]: Entering directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"\u001b[35m\u001b[1mConsolidate compiler generated dependencies of target lasp_cpp\u001b[0m\n",
|
|
||||||
"make[2]: Leaving directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"[100%] Built target lasp_cpp\n",
|
|
||||||
"make[1]: Leaving directory '/home/anne/wip/mycode/lasp'\n",
|
|
||||||
"make: Leaving directory '/home/anne/wip/mycode/lasp'\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"!make -j -C ~/wip/mycode/lasp"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "1787e24c",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"2022-07-20 22:04:50+0200 DebugTrace-cpp 2.0.0a2 (g++ 12.1.0)\n",
|
|
||||||
"2022-07-20 22:04:50+0200 \n",
|
|
||||||
"2022-07-20 22:04:50+0200 Enter fillUlDaqDeviceInfo (lasp_uldaq.cpp: 514)\n",
|
|
||||||
"2022-07-20 22:04:51+0200 Leave fillUlDaqDeviceInfo (lasp_uldaq.cpp)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"import lasp\n",
|
|
||||||
"ds = lasp.DeviceInfo.getDeviceInfo()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"id": "cb4ab7d8",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"init_daqconfiguration(pybind11::module_&)\r\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"!c++filt _Z21init_daqconfigurationRN8pybind117module_E"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 4,
|
|
||||||
"id": "22ae99b1",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"0: Monitor of Starship/Matisse HD Audio Controller Analog Stereo\n",
|
|
||||||
"1: Starship/Matisse HD Audio Controller Analog Stereo\n",
|
|
||||||
"2: GP108 High Definition Audio Controller Digital Stereo (HDMI)\n",
|
|
||||||
"3: Monitor of GP108 High Definition Audio Controller Digital Stereo (HDMI)\n",
|
|
||||||
"4: default\n",
|
|
||||||
"5: hw:HDA NVidia,3\n",
|
|
||||||
"6: hw:HDA NVidia,7\n",
|
|
||||||
"7: hw:HDA NVidia,8\n",
|
|
||||||
"8: hw:HDA NVidia,9\n",
|
|
||||||
"9: hw:HDA NVidia,10\n",
|
|
||||||
"10: hw:HD-Audio Generic,0\n",
|
|
||||||
"11: hw:HD-Audio Generic,1\n",
|
|
||||||
"12: hw:HD-Audio Generic,2\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"for i, d in enumerate(ds):\n",
|
|
||||||
" print(f'{i}: ' + d.device_name)\n",
|
|
||||||
"d = ds[1]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"id": "47385b02",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"config = lasp.DaqConfiguration(d)\n",
|
|
||||||
"config.outchannel_config[0].enabled = True\n",
|
|
||||||
"config.outchannel_config[1].enabled = True"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 59,
|
|
||||||
"id": "d12f84b7",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Out channels: 2\n",
|
|
||||||
"In channels: 0\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"print('Out channels:',d.noutchannels)\n",
|
|
||||||
"print('In channels:',d.ninchannels)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 52,
|
|
||||||
"id": "902ce309",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"mgr = lasp.StreamMgr.getInstance()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 55,
|
|
||||||
"id": "b209294b",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"2022-07-20 22:07:02+0200 \n",
|
|
||||||
"2022-07-20 22:07:02+0200 Enter createDaq (lasp_daq.cpp: 18)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 | Enter Daq (lasp_daq.cpp: 39)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 | Leave Daq (lasp_daq.cpp)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 | \n",
|
|
||||||
"2022-07-20 22:07:02+0200 | Enter RtAudioDaq (lasp_rtaudiodaq.cpp: 131)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 | Leave RtAudioDaq (lasp_rtaudiodaq.cpp)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 Leave createDaq (lasp_daq.cpp)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 isInput = false\n",
|
|
||||||
"2022-07-20 22:07:02+0200 isOutput = true\n",
|
|
||||||
"2022-07-20 22:07:02+0200 \n",
|
|
||||||
"2022-07-20 22:07:02+0200 Enter start (lasp_rtaudiodaq.cpp: 211)\n",
|
|
||||||
"2022-07-20 22:07:02+0200 Leave start (lasp_rtaudiodaq.cpp)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"mgr.startStream(d, config)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 27,
|
|
||||||
"id": "0830ffb5",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"#mgr.stopAllStreams()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 60,
|
|
||||||
"id": "a7fddc19",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"mgr.stopAllStreams()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 57,
|
|
||||||
"id": "f4610574",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"sine = lasp.Sine(200)\n",
|
|
||||||
"sine.setLevel(-20, True)\n",
|
|
||||||
"mgr.setSiggen(sine)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 21,
|
|
||||||
"id": "d11c7dae",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "0eeb2311",
|
|
||||||
"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.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""!
|
|
||||||
Author: J.A. de Jong - ASCEE
|
|
||||||
|
|
||||||
"""
|
|
||||||
import numpy as np
|
|
||||||
from lasp.filter.bandpass_limits import (third_octave_band_limits,
|
|
||||||
octave_band_limits, G, fr)
|
|
||||||
|
|
||||||
from lasp.filter.bandpass_fir import ThirdOctaveBankDesigner, \
|
|
||||||
OctaveBankDesigner
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
# Adjust these settings
|
|
||||||
b = 1 # or three
|
|
||||||
zoom = False # or True
|
|
||||||
|
|
||||||
if b == 3:
|
|
||||||
bands = ThirdOctaveBankDesigner()
|
|
||||||
elif b == 1:
|
|
||||||
bands = OctaveBankDesigner()
|
|
||||||
else:
|
|
||||||
raise ValueError('b should be 1 or 3')
|
|
||||||
|
|
||||||
|
|
||||||
for x in bands.xs:
|
|
||||||
fig = plt.figure()
|
|
||||||
ax = fig.add_subplot(111)
|
|
||||||
fs = 48000.
|
|
||||||
dec = np.prod(bands.decimation(x))
|
|
||||||
fd = fs/dec
|
|
||||||
fc = fd/2/1.4
|
|
||||||
|
|
||||||
freq = np.logspace(np.log10(1), np.log10(fd), 5000)
|
|
||||||
H = bands.freqResponse(fs, x, freq)
|
|
||||||
dBH = 20*np.log10(np.abs(H))
|
|
||||||
ax.semilogx(freq, dBH)
|
|
||||||
|
|
||||||
if b == 1:
|
|
||||||
freq, ulim, llim = octave_band_limits(x)
|
|
||||||
else:
|
|
||||||
freq, ulim, llim = third_octave_band_limits(x)
|
|
||||||
|
|
||||||
ax.semilogx(freq, llim)
|
|
||||||
ax.semilogx(freq, ulim)
|
|
||||||
ax.set_title(f'x = {x}, fnom = {bands.nominal_txt(x)}')
|
|
||||||
|
|
||||||
if zoom:
|
|
||||||
ax.set_xlim(bands.fl(x)/1.1, bands.fu(x)*1.1)
|
|
||||||
ax.set_ylim(-15, 1)
|
|
||||||
else:
|
|
||||||
ax.set_ylim(-75, 1)
|
|
||||||
ax.set_xlim(10, fd)
|
|
||||||
|
|
||||||
ax.axvline(fd/2)
|
|
||||||
if dec > 1:
|
|
||||||
ax.axvline(fc, color='red')
|
|
||||||
|
|
||||||
ax.legend(['Filter frequency response',
|
|
||||||
'Lower limit from standard',
|
|
||||||
'Upper limit from standard',
|
|
||||||
'Nyquist frequency after decimation',
|
|
||||||
'Decimation filter cut-off frequency'], fontsize=8)
|
|
||||||
|
|
||||||
plt.show()
|
|
@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Created on Mon Jan 15 19:45:33 2018
|
|
||||||
|
|
||||||
@author: anne
|
|
||||||
"""
|
|
||||||
import numpy as np
|
|
||||||
from lasp.wrappers import Fft
|
|
||||||
|
|
||||||
nfft=9
|
|
||||||
print('nfft:',nfft)
|
|
||||||
print(nfft)
|
|
||||||
nchannels = 4
|
|
||||||
|
|
||||||
t = np.linspace(0,1,nfft+1)[:-1]
|
|
||||||
# print(t)
|
|
||||||
#x1 = 1+np.sin(2*np.pi*t)+3.2*np.cos(2*np.pi*t)+np.sin(7*np.pi*t)
|
|
||||||
#x1 = np.sin(2*np.pi*t)
|
|
||||||
x1 = 1+0*t
|
|
||||||
x = np.vstack([x1.T]*nchannels).T
|
|
||||||
# Using transpose to get the strides right
|
|
||||||
x = np.random.randn(nchannels,nfft).T
|
|
||||||
# x.strides = (8,nfft*8)x
|
|
||||||
# print("signal:",x)
|
|
||||||
|
|
||||||
X = np.fft.rfft(x,axis=0)
|
|
||||||
print('Numpy fft')
|
|
||||||
print(X)
|
|
||||||
|
|
||||||
fft = Fft(nfft)
|
|
||||||
Y = fft.fft(x)
|
|
||||||
print('Beamforming fft')
|
|
||||||
print(Y)
|
|
||||||
|
|
||||||
x2 = fft.ifft(Y)
|
|
||||||
print('normdiff:',np.linalg.norm(x2-x))
|
|
||||||
print('end python script')
|
|
@ -1,46 +0,0 @@
|
|||||||
// test_bf.c
|
|
||||||
//
|
|
||||||
// Author: J.A. de Jong -ASCEE
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
#include "lasp_mat.h"
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
iVARTRACE(15,getTracerLevel());
|
|
||||||
/* vd vec1 = vd_alloc(3); */
|
|
||||||
/* vd_set(&vec1,2); */
|
|
||||||
|
|
||||||
/* vd vec2 = vd_alloc(3); */
|
|
||||||
/* vd_set(&vec2,3); */
|
|
||||||
|
|
||||||
/* print_vd(&vec1); */
|
|
||||||
|
|
||||||
/* vd res = vd_alloc(3); */
|
|
||||||
/* d_elem_prod_d(res.data,vec1.data,vec2.data,3); */
|
|
||||||
|
|
||||||
/* print_vd(&res); */
|
|
||||||
|
|
||||||
|
|
||||||
vc vc1 = vc_alloc(3);
|
|
||||||
vc_set(&vc1,2+2I);
|
|
||||||
print_vc(&vc1);
|
|
||||||
|
|
||||||
vc vc2 = vc_alloc(3);
|
|
||||||
vc_set(&vc2,2-2I);
|
|
||||||
setvecval(&vc2,0,10);
|
|
||||||
print_vc(&vc2);
|
|
||||||
|
|
||||||
|
|
||||||
vc res2 = vc_alloc(3);
|
|
||||||
c_hadamard(res2._data,vc1._data,vc2._data,3);
|
|
||||||
|
|
||||||
print_vc(&res2);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
45
test/test_fft.py
Normal file
45
test/test_fft.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Mon Jan 15 19:45:33 2018
|
||||||
|
|
||||||
|
@author: anne
|
||||||
|
"""
|
||||||
|
import numpy as np
|
||||||
|
from lasp import Fft, getFreq
|
||||||
|
|
||||||
|
def test_forward_fft():
|
||||||
|
"""
|
||||||
|
Test that our FFT implementation equals Numpy's rfft implementation
|
||||||
|
"""
|
||||||
|
nfft = 2048
|
||||||
|
t = np.linspace(0, 1.0, nfft, endpoint=False)
|
||||||
|
freq = 10
|
||||||
|
omg = 2*np.pi*freq
|
||||||
|
sig = np.cos(omg*t)+10
|
||||||
|
sig = np.random.randn(nfft)
|
||||||
|
fft_lasp = Fft(nfft)
|
||||||
|
|
||||||
|
res_lasp = fft_lasp.fft(sig)[:,0]
|
||||||
|
res_npy = np.fft.rfft(sig)
|
||||||
|
assert(np.isclose(np.linalg.norm(res_lasp- res_npy), 0))
|
||||||
|
|
||||||
|
def test_backward_fft():
|
||||||
|
"""
|
||||||
|
Test that our backward FFT implementation equals Numpy's rfft implementation
|
||||||
|
"""
|
||||||
|
nfft = 2048
|
||||||
|
freq = getFreq(nfft, nfft)
|
||||||
|
|
||||||
|
# Sig = np.zeros(nfft//2+1, dtype=complex)
|
||||||
|
Sigr = np.random.randn(nfft//2+1)
|
||||||
|
Sigi = np.random.randn(nfft//2+1)
|
||||||
|
|
||||||
|
Sig = Sigr + 1j*Sigi
|
||||||
|
|
||||||
|
fft_lasp = Fft(nfft)
|
||||||
|
sig_lasp = fft_lasp.ifft(Sig)[:,0]
|
||||||
|
sig_py = np.fft.irfft(Sig)
|
||||||
|
|
||||||
|
assert(np.isclose(np.linalg.norm(sig_py- sig_lasp), 0))
|
||||||
|
|
@ -1,89 +0,0 @@
|
|||||||
#include "lasp_cppdaq.h"
|
|
||||||
#include <chrono>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include <thread>
|
|
||||||
using std::cout;
|
|
||||||
using std::cerr;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
/* boolvec inChannels = {true, false, false, false}; */
|
|
||||||
auto devinfos = Daq::getDeviceInfo();
|
|
||||||
DeviceInfo devinfo;
|
|
||||||
us i;
|
|
||||||
bool found = false;
|
|
||||||
for(i=0;i<devinfos.size();i++) {
|
|
||||||
if(devinfos[i].api == uldaqapi){
|
|
||||||
cout << string(devinfos[i]) << endl;
|
|
||||||
devinfo = devinfos[i];
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found) {
|
|
||||||
throw runtime_error("Could not find UlDaq device");
|
|
||||||
}
|
|
||||||
|
|
||||||
DaqConfiguration config(devinfos[0]);
|
|
||||||
boolvec inChannels = {true, true, false, false};
|
|
||||||
boolvec outChannels = {true};
|
|
||||||
double samplerate = 10000;
|
|
||||||
const us samplesPerBlock = 256;
|
|
||||||
|
|
||||||
config.eninchannels = inChannels;
|
|
||||||
config.enoutchannels = outChannels;
|
|
||||||
config.sampleRateIndex = 0;
|
|
||||||
config.monitorOutput = true;
|
|
||||||
config.inputIEPEEnabled = {false, false, false, false};
|
|
||||||
cout << "Inchannnels size: " << config.eninchannels.size() << endl;
|
|
||||||
|
|
||||||
|
|
||||||
Daq* daq = Daq::createDaq(devinfo, config);
|
|
||||||
|
|
||||||
SafeQueue<void*> inqueue;
|
|
||||||
SafeQueue<void*> outqueue;
|
|
||||||
|
|
||||||
double totalTime = 5;
|
|
||||||
double t = 0;
|
|
||||||
double freq = 1000;
|
|
||||||
us nblocks = ((us) totalTime*samplerate/samplesPerBlock) + 10;
|
|
||||||
|
|
||||||
for(us i=0;i<nblocks;i++) {
|
|
||||||
|
|
||||||
double* data = static_cast<double*>(malloc(sizeof(double)*samplesPerBlock));
|
|
||||||
for(us sample=0;sample<samplesPerBlock;sample++) {
|
|
||||||
|
|
||||||
data[sample] = sin(2*M_PI*freq*t);
|
|
||||||
t+= 1.0/samplerate;
|
|
||||||
|
|
||||||
}
|
|
||||||
outqueue.enqueue(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
daq->start(&inqueue, &outqueue);
|
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds((int) totalTime));
|
|
||||||
|
|
||||||
daq->stop();
|
|
||||||
|
|
||||||
while(!inqueue.empty()) {
|
|
||||||
double* buf = (double*) inqueue.dequeue();
|
|
||||||
for(us i=0;i<samplesPerBlock;i++) {
|
|
||||||
for(us ch=0;ch<daq->neninchannels();ch++) {
|
|
||||||
cout << buf[ch*samplesPerBlock+i] << " ";
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
while(!outqueue.empty()){
|
|
||||||
void* dat = outqueue.dequeue();
|
|
||||||
free(dat);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
// test_bf.c
|
|
||||||
//
|
|
||||||
// Author: J.A. de Jong -ASCEE
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
#include "lasp_config.h"
|
|
||||||
#include "lasp_tracer.h"
|
|
||||||
#include "lasp_assert.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifdef LASP_PARALLEL
|
|
||||||
#include "lasp_worker.h"
|
|
||||||
#include "lasp_mq.h"
|
|
||||||
|
|
||||||
static void* walloc(void*);
|
|
||||||
static int worker(void*,void*);
|
|
||||||
static void wfree(void*);
|
|
||||||
#endif // LASP_PARALLEL
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
fsTRACE(15);
|
|
||||||
|
|
||||||
iVARTRACE(15,getTracerLevel());
|
|
||||||
|
|
||||||
#ifdef LASP_PARALLEL
|
|
||||||
us njobs = 4;
|
|
||||||
JobQueue* jq = JobQueue_alloc(njobs);
|
|
||||||
dbgassert(jq,NULLPTRDEREF);
|
|
||||||
|
|
||||||
Workers* w = Workers_create(njobs,
|
|
||||||
jq,
|
|
||||||
walloc,
|
|
||||||
worker,
|
|
||||||
wfree,
|
|
||||||
(void*) 101);
|
|
||||||
dbgassert(jq,NULLPTRDEREF);
|
|
||||||
|
|
||||||
for(us i=0; i< njobs; i++) {
|
|
||||||
iVARTRACE(15,i);
|
|
||||||
JobQueue_push(jq,(void*) i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
JobQueue_wait_alldone(jq);
|
|
||||||
Workers_free(w);
|
|
||||||
JobQueue_free(jq);
|
|
||||||
|
|
||||||
#endif // LASP_PARALLEL
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#ifdef LASP_PARALLEL
|
|
||||||
static void* walloc(void* data) {
|
|
||||||
TRACE(15,"WALLOC");
|
|
||||||
uVARTRACE(15,(us) data);
|
|
||||||
return (void*) 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int worker(void* w_data,void* tj) {
|
|
||||||
|
|
||||||
TRACE(15,"worker");
|
|
||||||
|
|
||||||
sleep(4);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
static void wfree(void* w_data) {
|
|
||||||
TRACE(15,"wfree");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LASP_PARALLEL
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user