metasona 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. metasona-0.1.0/CMakeLists.txt +183 -0
  2. metasona-0.1.0/LICENSE +674 -0
  3. metasona-0.1.0/LICENSES/Apache-2.0.txt +201 -0
  4. metasona-0.1.0/LICENSES/BSD-3-Clause-PA-Tonality.txt +28 -0
  5. metasona-0.1.0/LICENSES/BSD-3-Clause-PocketFFT.txt +25 -0
  6. metasona-0.1.0/LICENSES/BSD-3-Clause-SQAT.txt +27 -0
  7. metasona-0.1.0/LICENSES/MIT-SQAT.txt +21 -0
  8. metasona-0.1.0/NOTICE +36 -0
  9. metasona-0.1.0/PKG-INFO +142 -0
  10. metasona-0.1.0/README.md +104 -0
  11. metasona-0.1.0/THIRD_PARTY.md +107 -0
  12. metasona-0.1.0/cmake/MetaSonaConfig.cmake.in +7 -0
  13. metasona-0.1.0/docs/c-api.md +230 -0
  14. metasona-0.1.0/docs/python-api.md +149 -0
  15. metasona-0.1.0/examples/CMakeLists.txt +10 -0
  16. metasona-0.1.0/examples/metasona_example.c +125 -0
  17. metasona-0.1.0/examples/metasona_example.py +67 -0
  18. metasona-0.1.0/include/metasona/metasona.h +195 -0
  19. metasona-0.1.0/pyproject.toml +123 -0
  20. metasona-0.1.0/python/metasona/__init__.py +58 -0
  21. metasona-0.1.0/python/metasona/_abi.py +280 -0
  22. metasona-0.1.0/python/metasona/_api.py +303 -0
  23. metasona-0.1.0/python/metasona/_resample.py +48 -0
  24. metasona-0.1.0/python/metasona/_types.py +112 -0
  25. metasona-0.1.0/python/metasona/_validation.py +116 -0
  26. metasona-0.1.0/python/metasona/exceptions.py +28 -0
  27. metasona-0.1.0/python/metasona/py.typed +1 -0
  28. metasona-0.1.0/src/metasona.c +125 -0
  29. metasona-0.1.0/src/ms_internal.h +28 -0
  30. metasona-0.1.0/src/ms_loudness.c +577 -0
  31. metasona-0.1.0/src/ms_loudness_data.h +160 -0
  32. metasona-0.1.0/src/ms_sharpness.c +57 -0
  33. metasona-0.1.0/src/ms_signal_metrics.c +93 -0
  34. metasona-0.1.0/src/roughness_dw.c +726 -0
  35. metasona-0.1.0/src/roughness_dw.h +61 -0
  36. metasona-0.1.0/src/third_party/pocketfft/LICENSE.md +25 -0
  37. metasona-0.1.0/src/third_party/pocketfft/README.md +24 -0
  38. metasona-0.1.0/src/third_party/pocketfft/pocketfft.c +2190 -0
  39. metasona-0.1.0/src/third_party/pocketfft/pocketfft.h +34 -0
  40. metasona-0.1.0/src/tonality_aures1985.c +646 -0
  41. metasona-0.1.0/src/tonality_aures1985.h +76 -0
  42. metasona-0.1.0/src/tonality_narrowband.h +157 -0
@@ -0,0 +1,183 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ cmake_minimum_required(VERSION 3.21)
4
+
5
+ project(
6
+ metasona
7
+ VERSION 0.1.0
8
+ DESCRIPTION "Source-informed psychoacoustic metrics library"
9
+ LANGUAGES C
10
+ )
11
+
12
+ include(GNUInstallDirs)
13
+ include(CMakePackageConfigHelpers)
14
+
15
+ option(MS_BUILD_SHARED "Build a shared native library" ON)
16
+ option(MS_ENABLE_SANITIZERS "Enable AddressSanitizer and UndefinedBehaviorSanitizer" OFF)
17
+ option(MS_WARNINGS_AS_ERRORS "Treat project warnings as errors" ON)
18
+ set(MS_ABI_SOVERSION 1 CACHE STRING "Native shared-library ABI version")
19
+
20
+ set(MS_LIBRARY_TYPE STATIC)
21
+ if(MS_BUILD_SHARED)
22
+ set(MS_LIBRARY_TYPE SHARED)
23
+ endif()
24
+
25
+ # Keep pinned upstream code unchanged and isolate its warning policy from
26
+ # project code. Prefix and hide its symbols in both static and shared builds.
27
+ add_library(ms_pocketfft OBJECT src/third_party/pocketfft/pocketfft.c)
28
+ add_library(ms_psychoacoustics OBJECT src/roughness_dw.c src/tonality_aures1985.c)
29
+ target_include_directories(ms_psychoacoustics PRIVATE src/third_party/pocketfft src include)
30
+ target_compile_definitions(ms_psychoacoustics PRIVATE
31
+ MS_BUILDING_LIBRARY=1 TONALITY_AURES1985_STATIC=1
32
+ roughness_dw=ms_roughness_kernel tonality_aures1985=ms_tonality_kernel)
33
+ set_target_properties(ms_psychoacoustics PROPERTIES
34
+ C_STANDARD 11 C_STANDARD_REQUIRED YES C_EXTENSIONS NO
35
+ POSITION_INDEPENDENT_CODE YES C_VISIBILITY_PRESET hidden)
36
+ set_target_properties(ms_pocketfft PROPERTIES
37
+ C_STANDARD 11 C_STANDARD_REQUIRED YES C_EXTENSIONS NO
38
+ POSITION_INDEPENDENT_CODE YES C_VISIBILITY_PRESET hidden)
39
+ if(MSVC)
40
+ target_compile_options(ms_pocketfft PRIVATE /fp:precise /Brepro)
41
+ target_compile_options(ms_psychoacoustics PRIVATE /fp:precise /Brepro)
42
+ else()
43
+ target_compile_options(ms_pocketfft PRIVATE -ffp-contract=off)
44
+ target_compile_options(ms_psychoacoustics PRIVATE -ffp-contract=off)
45
+ endif()
46
+
47
+ add_library(metasona ${MS_LIBRARY_TYPE}
48
+ src/metasona.c
49
+ src/ms_loudness.c
50
+ src/ms_signal_metrics.c
51
+ src/ms_sharpness.c
52
+ $<TARGET_OBJECTS:ms_pocketfft>
53
+ $<TARGET_OBJECTS:ms_psychoacoustics>
54
+ )
55
+ target_compile_definitions(metasona PRIVATE
56
+ TONALITY_AURES1985_STATIC=1
57
+ roughness_dw=ms_roughness_kernel tonality_aures1985=ms_tonality_kernel)
58
+ foreach(symbol make_cfft_plan destroy_cfft_plan cfft_backward cfft_forward cfft_length
59
+ make_rfft_plan destroy_rfft_plan rfft_backward rfft_forward rfft_length)
60
+ target_compile_definitions(ms_pocketfft PRIVATE "${symbol}=ms_pocketfft_${symbol}")
61
+ target_compile_definitions(ms_psychoacoustics PRIVATE "${symbol}=ms_pocketfft_${symbol}")
62
+ target_compile_definitions(metasona PRIVATE "${symbol}=ms_pocketfft_${symbol}")
63
+ endforeach()
64
+ add_library(MetaSona::metasona ALIAS metasona)
65
+
66
+ set_target_properties(metasona PROPERTIES
67
+ C_STANDARD 11
68
+ C_STANDARD_REQUIRED YES
69
+ C_EXTENSIONS NO
70
+ POSITION_INDEPENDENT_CODE YES
71
+ C_VISIBILITY_PRESET hidden
72
+ VISIBILITY_INLINES_HIDDEN YES
73
+ WINDOWS_EXPORT_ALL_SYMBOLS OFF
74
+ )
75
+ if(NOT SKBUILD)
76
+ set_target_properties(metasona PROPERTIES
77
+ VERSION ${PROJECT_VERSION}
78
+ SOVERSION ${MS_ABI_SOVERSION}
79
+ )
80
+ endif()
81
+ target_compile_definitions(metasona PRIVATE MS_BUILDING_LIBRARY=1)
82
+ if(NOT MS_BUILD_SHARED)
83
+ target_compile_definitions(metasona PUBLIC MS_STATIC=1)
84
+ target_compile_definitions(ms_psychoacoustics PRIVATE MS_STATIC=1)
85
+ endif()
86
+ target_include_directories(metasona
87
+ PUBLIC
88
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
89
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
90
+ PRIVATE
91
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
92
+ )
93
+
94
+ if(MSVC)
95
+ target_compile_options(metasona PRIVATE /W4 /permissive- /sdl /fp:precise /Brepro)
96
+ target_link_options(metasona PRIVATE /Brepro)
97
+ if(MS_WARNINGS_AS_ERRORS)
98
+ target_compile_options(metasona PRIVATE /WX)
99
+ endif()
100
+ else()
101
+ target_compile_options(metasona PRIVATE
102
+ -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wstrict-prototypes
103
+ -Wsign-conversion -Wmissing-prototypes -Wdouble-promotion -Wformat=2
104
+ -ffp-contract=off
105
+ )
106
+ if(MS_WARNINGS_AS_ERRORS)
107
+ target_compile_options(metasona PRIVATE -Werror)
108
+ endif()
109
+ target_link_libraries(metasona PRIVATE m)
110
+ endif()
111
+
112
+ if(MS_ENABLE_SANITIZERS)
113
+ if(MSVC)
114
+ target_compile_options(ms_pocketfft PRIVATE /fsanitize=address)
115
+ target_compile_options(ms_psychoacoustics PRIVATE /fsanitize=address)
116
+ target_compile_options(metasona PRIVATE /fsanitize=address)
117
+ target_link_options(metasona PRIVATE /INFERASANLIBS)
118
+ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
119
+ target_compile_options(ms_pocketfft PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer)
120
+ target_compile_options(ms_psychoacoustics PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer)
121
+ target_compile_options(metasona PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer)
122
+ target_link_options(metasona PRIVATE -fsanitize=address,undefined)
123
+ else()
124
+ message(FATAL_ERROR "Sanitizers are not configured for ${CMAKE_C_COMPILER_ID}")
125
+ endif()
126
+ endif()
127
+
128
+ if(SKBUILD)
129
+ set(MS_RUNTIME_INSTALL_DIR "metasona/_native")
130
+ set(MS_LIBRARY_INSTALL_DIR "metasona/_native")
131
+ else()
132
+ set(MS_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
133
+ set(MS_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
134
+ endif()
135
+
136
+ install(TARGETS metasona
137
+ EXPORT MetaSonaTargets
138
+ RUNTIME DESTINATION "${MS_RUNTIME_INSTALL_DIR}" COMPONENT Runtime
139
+ LIBRARY DESTINATION "${MS_LIBRARY_INSTALL_DIR}" COMPONENT Runtime
140
+ NAMELINK_COMPONENT Development
141
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Development
142
+ )
143
+ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
144
+ COMPONENT Development)
145
+
146
+ configure_package_config_file(
147
+ cmake/MetaSonaConfig.cmake.in
148
+ ${CMAKE_CURRENT_BINARY_DIR}/MetaSonaConfig.cmake
149
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MetaSona
150
+ )
151
+ write_basic_package_version_file(
152
+ ${CMAKE_CURRENT_BINARY_DIR}/MetaSonaConfigVersion.cmake
153
+ VERSION ${PROJECT_VERSION}
154
+ COMPATIBILITY SameMajorVersion
155
+ )
156
+ install(EXPORT MetaSonaTargets
157
+ NAMESPACE MetaSona::
158
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MetaSona
159
+ COMPONENT Development
160
+ )
161
+ install(FILES
162
+ ${CMAKE_CURRENT_BINARY_DIR}/MetaSonaConfig.cmake
163
+ ${CMAKE_CURRENT_BINARY_DIR}/MetaSonaConfigVersion.cmake
164
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MetaSona
165
+ COMPONENT Development
166
+ )
167
+ install(FILES LICENSE NOTICE THIRD_PARTY.md
168
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/MetaSona"
169
+ COMPONENT Runtime
170
+ )
171
+ install(FILES LICENSE NOTICE THIRD_PARTY.md
172
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/MetaSona"
173
+ COMPONENT Development
174
+ )
175
+
176
+ install(DIRECTORY LICENSES/
177
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/MetaSona/LICENSES"
178
+ COMPONENT Runtime
179
+ )
180
+ install(DIRECTORY LICENSES/
181
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/MetaSona/LICENSES"
182
+ COMPONENT Development
183
+ )