Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/ambitap/ambitap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "dsp/spatial_compressor.h"
#include "dsp/util/async_rebuilder.h"
#include "dsp/virtual_mic.h"
#include "dsp/xtc.h"
#include "math/binaural/convolution.h"
#include "math/binaural/hrtf_data.h"
#include "math/binaural/ooura_fft.h"
Expand Down
559 changes: 559 additions & 0 deletions include/ambitap/dsp/xtc.h

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions notebooks/ambitap_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def load() -> ctypes.CDLL:
ctypes.c_int),
"ambitap_builtin_hrtf_info": ([i32p, i32p, i32p, f32p], ctypes.c_int),
"ambitap_builtin_hrtf_fir": ([ctypes.c_int, ctypes.c_int, ctypes.c_int, f32p], ctypes.c_int),
"ambitap_builtin_hrtf_hrir": (
[ctypes.c_int, ctypes.c_int, ctypes.c_float, ctypes.c_float, f32p, f32p], ctypes.c_int),
"ambitap_resample_fir": (
[f32p, ctypes.c_int, ctypes.c_float, ctypes.c_float, f32p, ctypes.c_int], ctypes.c_int),
"ambitap_convolve": (
Expand Down Expand Up @@ -197,6 +199,21 @@ def builtin_hrtf(magls: bool = False) -> tuple[np.ndarray, np.ndarray]:
return ears[0], ears[1]


def builtin_hrtf_hrir(azimuth: float, elevation: float, *, order: int | None = None,
magls: bool = False) -> tuple[np.ndarray, np.ndarray]:
"""Time-domain SH-reconstructed KEMAR HRIR at a direction — the weighted
sum inside binaural_renderer::probe_response: (left, right), each
builtin length taps at the builtin sample rate."""
if order is None:
order = builtin_hrtf_info()["order"]
length = builtin_hrtf_info()["length"]
left = np.empty(length, dtype=np.float32)
right = np.empty(length, dtype=np.float32)
_check(_LIB.ambitap_builtin_hrtf_hrir(order, int(magls), float(azimuth), float(elevation),
_ptr(left), _ptr(right)), "builtin_hrtf_hrir")
return left, right


def resample_fir(x: np.ndarray, in_rate: float, out_rate: float) -> np.ndarray:
x = _f32(x)
cap = int(np.ceil(len(x) * out_rate / in_rate)) + 8
Expand Down
545 changes: 545 additions & 0 deletions notebooks/room_model.py

Large diffs are not rendered by default.

1,260 changes: 1,260 additions & 0 deletions notebooks/room_verification.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_executable(ambitap_tests
test_rt_safety.cpp
test_embedded_core.cpp
test_sofa.cpp
test_xtc.cpp
)
target_link_libraries(ambitap_tests PRIVATE
AmbiTap::ambitap ambitap_warnings GTest::gtest_main)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_rt_safety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ambitap/dsp/rotator.h"
#include "ambitap/dsp/spatial_compressor.h"
#include "ambitap/dsp/virtual_mic.h"
#include "ambitap/dsp/xtc.h"
#include "ambitap/math/geometry/layouts.h"

#include <gtest/gtest.h>
Expand Down Expand Up @@ -273,6 +274,23 @@ TEST(RtSafety, StatefulProcessorsAreAllocationFree) {
EXPECT_EQ(guard.frees(), 0);
}

TEST(RtSafety, XtcProcessIsAllocationFree) {
constexpr size_t block = 64;

dsp::xtc x;
x.prepare(block, 48000.f);

std::vector<float> in_l(block, 0.25f), in_r(block, -0.25f);
std::vector<float> out_l(block), out_r(block);

rt_guard guard;
for (int i = 0; i < 8; ++i) {
x.process(in_l.data(), in_r.data(), out_l.data(), out_r.data(), block);
}
EXPECT_EQ(guard.allocations(), 0);
EXPECT_EQ(guard.frees(), 0);
}

TEST(RtSafety, BinauralRendererProcessIsAllocationFree) {
constexpr size_t block = 64;

Expand Down
Loading
Loading