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

Fix structure of RmeMtx and RmmMtx in obsFiltTD.m

parent 8fffad1b
No related branches found
No related tags found
1 merge request!4Fix time-domain calculations of the optimal observation filter
This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
...@@ -211,27 +211,24 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -211,27 +211,24 @@ 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, lags] = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx)); corr = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx), filtLen, "unbiased");
lIdx = find(lags == 0);
Rme(:, mIdx, eIdx, jIdx) = corr(lIdx:-1:lIdx-filtLen + 1); Rme(:, mIdx, eIdx, jIdx) = corr(filtLen + 1:-1:2);
end end
% Go through the monitoring microphones to calculate the monitoring microphone correlation matrices % Go through the monitoring microphones to calculate the monitoring microphone correlation matrices
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, lags] = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx)); corr = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased");
lIdx = find(lags == 0);
Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(lIdx:-1:lIdx - filtLen + 1)); Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(filtLen + 1:-1:2));
else else
[corr, lags] = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx)); corr = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased");
lIdx = find(lags == 0);
% Cross-correlation matrices % Cross-correlation matrices
for iIdx = filtLen-1:-1:0 for iIdx = filtLen-1:-1:0
Rmm(:, iIdx + 1, mIdx, mmIdx, jIdx) = corr(iIdx + (lIdx:-1:lIdx - filtLen + 1)); Rmm(:, iIdx + 1, mIdx, mmIdx, jIdx) = corr(iIdx + (filtLen + 1:-1:2));
end end
Rmm(:, :, mmIdx, mIdx, jIdx) = squeeze(Rmm(:, :, mIdx, mmIdx, jIdx)).'; Rmm(:, :, mmIdx, mIdx, jIdx) = squeeze(Rmm(:, :, mIdx, mmIdx, jIdx)).';
end end
...@@ -243,8 +240,8 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM ...@@ -243,8 +240,8 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM
% Post-process cross- and auto-correlation matrices % Post-process cross- and auto-correlation matrices
% ==================================================== % ====================================================
% "Reshape" the data % "Reshape" the data
RmeMtx = reshape(Rme, prod(size(Rme, [1, 2])), size(Rme, 3), size(Rme, 4)); RmeMtx = reshape(permute(Rme, [2, 1, 3, 4]), prod(size(Rme, [1, 2])), size(Rme, 3), size(Rme, 4));
RmmMtx = reshape(permute(Rmm, [1, 3, 2, 4, 5]), prod(size(Rmm, [1, 3])), prod(size(Rmm, [2, 4])), size(Rmm, 5)); RmmMtx = reshape(permute(Rmm, [3, 1, 4, 2, 5]), prod(size(Rmm, [1, 3])), prod(size(Rmm, [2, 4])), size(Rmm, 5));
% ==================================================== % ====================================================
% Calculate observation filters % Calculate observation filters
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment