-
Notifications
You must be signed in to change notification settings - Fork 3
/
getLsFilters.m
37 lines (33 loc) · 1.74 KB
/
getLsFilters.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [wLsL, wLsR] = getLsFilters(hL, hR, hrirGridAziRad, hrirGridZenRad, order, ...
shDefinition, shFunction)
% [wLsL, wLsR] = getLsFilters(hL, hR, hrirGridAziRad, hrirGridZenRad, order, ...
% shDefinition, shFunction)
%
% This function calculates least-squares decoding filters for head related impulse response data sets.
% For more information, please refer to
% Schörkhuber, Zaunschirm, and Hoeldrich,
% “Binaural Rendering of Ambisonic Signals via Magnitude Least Squares,”
% in Fortschritte der Akustik -- DAGA 2018, 2018, pp. 339–342.
%
% wLsL .. time-domain decoding filter for left ear
% wLsR .. time-domain decoding filter for right ear
% hL .. HRIR set for left ear (numSamples x numDirections)
% hR .. HRIR set for right ear (numSamples x numDirections)
% hrirGridAziRad .. grid azimuth angles in radians of HRIR set (numDirections x 1)
% hrirGridZenRad .. grid zenith angles in radians of HRIR set (numDirections x 1)
% order .. SH output order
% shDefinition .. SH basis type according to utilized shFunction, default: 'real'
% shFunction .. SH basis function (see testEMagLs.m for example), default: @getSH
%
% This software is licensed under a Non-Commercial Software License
% (see https://github.com/thomasdeppisch/eMagLS/blob/main/LICENSE for full details).
%
% Thomas Deppisch, 2023
if nargin < 7; shFunction = @getSH; end
if nargin < 6 || isempty(shDefinition); shDefinition = 'real'; end
fprintf('with @%s("%s") ... ', func2str(shFunction), shDefinition);
Y_conj = shFunction(order, [hrirGridAziRad, hrirGridZenRad], shDefinition)';
Y_pinv = pinv(Y_conj);
wLsL = hL * Y_pinv;
wLsR = hR * Y_pinv;
end