Skip to content
Snippets Groups Projects
Commit 89745645 authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Remove scaling from cross-correlations and reshape observation filters with...

Remove scaling from cross-correlations and reshape observation filters with single liners instead of loops in obsFiltTD.m
parent bf1d1ecd
No related branches found
No related tags found
1 merge request!4Fix time-domain calculations of the optimal observation filter
...@@ -211,7 +211,7 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -211,7 +211,7 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM
for mIdx = size(m, 2):-1:1 for mIdx = size(m, 2):-1:1
% Calculate the cross-correlations between virtual and monitoring microphones % Calculate the cross-correlations between virtual and monitoring microphones
for eIdx = size(e, 2):-1:1 for eIdx = size(e, 2):-1:1
corr = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx), filtLen, "unbiased"); corr = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx), filtLen);
Rme(:, mIdx, eIdx, jIdx) = corr(filtLen + 1:-1:2); Rme(:, mIdx, eIdx, jIdx) = corr(filtLen + 1:-1:2);
end end
...@@ -220,11 +220,11 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -220,11 +220,11 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM
for mmIdx = mIdx:-1:1 for mmIdx = mIdx:-1:1
% Auto-correlation matrices are Toeplitz symmetric % Auto-correlation matrices are Toeplitz symmetric
if mIdx == mmIdx if mIdx == mmIdx
corr = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased"); corr = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx), filtLen);
Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(filtLen + 1:-1:2)); Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(filtLen + 1:-1:2));
else else
corr = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased"); corr = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx), filtLen);
% Cross-correlation matrices % Cross-correlation matrices
for iIdx = filtLen-1:-1:0 for iIdx = filtLen-1:-1:0
...@@ -250,12 +250,8 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -250,12 +250,8 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM
Ovec(:, :, jIdx) = RmeMtx(:, :, jIdx).'/(RmmMtx(:, :, jIdx) + beta * eye(size(RmmMtx, 1))); Ovec(:, :, jIdx) = RmeMtx(:, :, jIdx).'/(RmmMtx(:, :, jIdx) + beta * eye(size(RmmMtx, 1)));
end end
% "Split" observation filter vector to observation filters per monitoring and virtual microphone % "Split" observation filter vector to observation filters per monitoring and virtual microphone
for jIdx = size(Ovec, 3):-1:1 O = permute(reshape(Ovec, size(Ovec, 1), size(m, 2), filtLen, size(Ovec, 3)), [1, 3, 2, 4]);
for mIdx = size(m, 2):-1:1
O(:, :, mIdx, jIdx) = Ovec(:, mIdx:size(m, 2):end, jIdx);
end
end
% ==================================================== % ====================================================
% Provide additional output arguments % Provide additional output arguments
...@@ -282,9 +278,7 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -282,9 +278,7 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM
Oopt = RmeMtxMean.'/(RmmMtxMean + beta * eye(size(RmmMtxMean))); Oopt = RmeMtxMean.'/(RmmMtxMean + beta * eye(size(RmmMtxMean)));
% Reshape % Reshape
for mIdx = size(m, 2):-1:1 Omean = permute(reshape(Oopt, size(Oopt, 1), size(m, 2), filtLen), [1, 3, 2]);
Omean(:, :, mIdx) = Oopt(:, mIdx:size(m, 2):end);
end
end end
% Mean cross-correlations between monitoring and virtual microphones over trials/sound field realisations % Mean cross-correlations between monitoring and virtual microphones over trials/sound field realisations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment