From c50638aa28838ffa79c4e7b03fbf8f1bebd673c8 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 18:33:16 +0100 Subject: [PATCH 1/6] Fix bug in obsFilt.m to allow for negative values in the source strength PSD matrix so that complex numbers can be used --- .../MATLAB/Functions/obsFilt.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m index 0c4bb05..2431f64 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 01/09/2024 (DD/MM/YYYY) +% Date: 04/09/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -91,7 +91,12 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal) % Validate optional arguments if nargin > 2 && ~isempty(srcCsd) - validateattributes(srcCsd, "numeric", {'2d', 'nonnegative', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + validateattributes(srcCsd, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + + % Check for correct dimensions + if diff(size(srcCsd)) + error("The source power spectral density matrix must be a square matrix"); + end else srcCsd = eye(size(Pe, 2)); end -- GitLab From bc876f99800eee575b6eed665944ed5536474055 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 18:37:08 +0100 Subject: [PATCH 2/6] Add check for corrrect dimension of Svv in obsFilt.m --- .../Remote Microphone Technique/MATLAB/Functions/obsFilt.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m index 2431f64..846e087 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m @@ -96,6 +96,8 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal) % Check for correct dimensions if diff(size(srcCsd)) error("The source power spectral density matrix must be a square matrix"); + elseif size(srcCsd, 1) ~= size(Pe, 1) + error("The number of rows of the source power spectral density matrix must be equal to the number of sources"); end else srcCsd = eye(size(Pe, 2)); -- GitLab From 80575f59952dc70de41aa9ead3be17474505ef21 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 18:37:43 +0100 Subject: [PATCH 3/6] Add checks for the dimensions of Svv in obsFiltEst.m --- .../MATLAB/Functions/obsFiltEst.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m index ae04ff9..c01a20e 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 23/08/2024 (DD/MM/YYYY) +% Date: 04/09/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -83,7 +83,14 @@ function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, srcCsd) end if nargin > 3 && ~isempty(srcCsd) - validateattributes(srcCsd, "numeric", {'2d', 'nonnegative', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + validateattributes(srcCsd, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + + % Check for correct dimensions + if diff(size(srcCsd)) + error("The source power spectral density matrix must be a square matrix"); + elseif size(srcCsd, 1) ~= size(Pe, 1) + error("The number of rows of the source power spectral density matrix must be equal to the number of sources"); + end else srcCsd = eye(size(Pe, 2)); end -- GitLab From cbb81fe89a2bf38559b73f9f73dd9847e43837e8 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 18:39:58 +0100 Subject: [PATCH 4/6] Changed variable name of srcCsd to Svv in obsFilt.m --- .../MATLAB/Functions/obsFilt.m | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m index 846e087..a36d8f4 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFilt.m @@ -22,10 +22,10 @@ % where K is the number of monitoring microphones and M is % the number of sources. % -% srcCsd [numeric] (Optional): The source cross spectral density matrix. -% This must be a square (MxM) symmetric matrix -% with the cross power spectral density of the -% sources. [Default: eye(M)] +% Svv [numeric] (Optional): The source cross spectral density matrix. This +% must be a square (MxM) symmetric matrix with +% the cross power spectral density of the +% sources. [Default: eye(M)] % % regFacs [numeric] (Optional): The regularisation factors used for the % inversion of the cross-spectra of the @@ -75,7 +75,7 @@ % for local active sound control" by W. Jung, S. J. Elliott and J. Cheer. % % -------------------------------------------------- -function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal) +function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, Svv, regFacs, snrVal) % ==================================================== % Check for number of arguments % ==================================================== @@ -90,17 +90,17 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal) validateattributes(Pm, "numeric", {'nonnan', 'nonempty', 'finite'}, mfilename, "Monitoring microphone pressure", 2); % Validate optional arguments - if nargin > 2 && ~isempty(srcCsd) - validateattributes(srcCsd, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + if nargin > 2 && ~isempty(Svv) + validateattributes(Svv, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) % Check for correct dimensions - if diff(size(srcCsd)) + if diff(size(Svv)) error("The source power spectral density matrix must be a square matrix"); - elseif size(srcCsd, 1) ~= size(Pe, 1) + elseif size(Svv, 1) ~= size(Pe, 1) error("The number of rows of the source power spectral density matrix must be equal to the number of sources"); end else - srcCsd = eye(size(Pe, 2)); + Svv = eye(size(Pe, 2)); end if nargin > 3 && ~isempty(regFacs) @@ -134,7 +134,7 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, srcCsd, regFacs, snrVal) % Calculate optimal filters % ==================================================== % Calculate needed quantities - tmpVal = srcCsd * Pm'; + tmpVal = Svv * Pm'; Sme = Pe * tmpVal; % Virtual-Monitor mics cross-spectra Smm = Pm * tmpVal; % Monitor-Monitor mics cross-spectra -- GitLab From 039885ea139ff6e15d14320a8ab83d404add1cb0 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 18:40:27 +0100 Subject: [PATCH 5/6] Changed variable name of srcCsd to Svv in obsFiltEst.m --- .../MATLAB/Functions/obsFiltEst.m | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m index c01a20e..3a799bd 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltEst.m @@ -28,10 +28,10 @@ % matrix must be NxM, where N is the number of % virtual microphones and M the number of sources. % -% srcCsd [numeric] (Optional): The source cross spectral density matrix. -% This must be a square (MxM) symmetric matrix -% with the cross power spectral density of the -% sources. [Default: eye(M)] +% Svv [numeric] (Optional): The source cross spectral density matrix. This +% must be a square (MxM) symmetric matrix with +% the cross power spectral density of the +% sources. [Default: eye(M)] % % -------------------------------------------------- % Output @@ -60,7 +60,7 @@ % Notes % % -------------------------------------------------- -function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, srcCsd) +function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, Svv) % ==================================================== % Check for number of arguments % ==================================================== @@ -82,17 +82,17 @@ function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, srcCsd) Pe = NaN; end - if nargin > 3 && ~isempty(srcCsd) - validateattributes(srcCsd, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) + if nargin > 3 && ~isempty(Svv) + validateattributes(Svv, "numeric", {'2d', 'nonnan', 'finite'}, mfilename, "Source cross spectral density matrix", 3) % Check for correct dimensions - if diff(size(srcCsd)) + if diff(size(Svv)) error("The source power spectral density matrix must be a square matrix"); - elseif size(srcCsd, 1) ~= size(Pe, 1) + elseif size(Svv, 1) ~= size(Pe, 1) error("The number of rows of the source power spectral density matrix must be equal to the number of sources"); end else - srcCsd = eye(size(Pe, 2)); + Svv = eye(size(Pe, 2)); end @@ -110,7 +110,7 @@ function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, srcCsd) % Sum of squared estimation errors if nargout > 2 for eIdx = size(Pe, 1):-1:1 - errSqr(eIdx) = err(eIdx, :) * srcCsd * err(eIdx, :)'; + errSqr(eIdx) = err(eIdx, :) * Svv * err(eIdx, :)'; end errSqr = errSqr.'; @@ -119,7 +119,7 @@ function [est, err, errSqr, normErrSqr, See] = obsFiltEst(Pm, O, Pe, srcCsd) % Normalised squared errors if nargout > 3 for eIdx = length(errSqr):-1:1 - See(eIdx) = Pe(eIdx, :) * srcCsd * Pe(eIdx, :)'; + See(eIdx) = Pe(eIdx, :) * Svv * Pe(eIdx, :)'; normErrSqr(eIdx) = errSqr(eIdx)/See(eIdx); end -- GitLab From 182b517bbc9c86f7b10bfc5df6eafdd7b7d9b2e0 Mon Sep 17 00:00:00 2001 From: Achilles Kappis <axilleaz@protonmail.com> Date: Wed, 4 Sep 2024 17:49:48 +0000 Subject: [PATCH 6/6] Update the project version in the project README.md file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc62d9b..fd23c6f 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ The project is licensed under the ***MIT License***, which is a rather unrestric ## Versioning ## -The project uses [semantic versioning](https://semver.org/) and the current version is **v0.2.1**. +The project uses [semantic versioning](https://semver.org/) and the current version is **v0.2.2**. #### **Important** -- GitLab